org.freehep.swing
Class RecentFileList

java.lang.Object
  extended by org.freehep.swing.RecentFileList
All Implemented Interfaces:
ActionListener, EventListener

public class RecentFileList
extends Object
implements ActionListener

A class for maintaining a "Recent File List". The recent file list can be stored between program invocations in a properties file. One or more RecentFileLists can easily be embedded in a JMenu.

Version:
$Id: RecentFileList.java 8584 2006-08-10 23:06:37Z duns $
Author:
Tony Johnson (tonyj@slac.stanford.edu)

Constructor Summary
RecentFileList()
          Create a RecentFileList
RecentFileList(int size)
          Create a RecentFileList with a given maximum length
RecentFileList(String type)
          Create a recent file list.
RecentFileList(String type, int size)
          Create a recent file list with a given type and size
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void add(File f)
          Add a file to the list
 void add(String name)
          Add a file to the list
 void addActionListener(ActionListener l)
           
 void buildMenu(JMenu menu)
          Adds the recent file list to a menu.
 void load(Properties props)
          Load the recent file list from a Properties set
 void remove(File f)
          Remove a file from the list
 void remove(String name)
          Remove a file from the list
 void removeActionListener(ActionListener l)
           
 void save(Properties props)
          Save the recent file list in a Properties set
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecentFileList

public RecentFileList()
Create a RecentFileList


RecentFileList

public RecentFileList(int size)
Create a RecentFileList with a given maximum length

Parameters:
size - the maximum number of files to remember

RecentFileList

public RecentFileList(String type)
Create a recent file list. The type parameter is used to prefix entries in the properties file, so that multiple RecentFileLists can be used in an application.

Parameters:
type - The prefix to use

RecentFileList

public RecentFileList(String type,
                      int size)
Create a recent file list with a given type and size

Parameters:
type - The prefix to use
size - the maximum number of files to remember
Method Detail

addActionListener

public void addActionListener(ActionListener l)

removeActionListener

public void removeActionListener(ActionListener l)

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

save

public void save(Properties props)
Save the recent file list in a Properties set

Parameters:
props - The Properties set to save the files in

load

public void load(Properties props)
Load the recent file list from a Properties set

Parameters:
props - The Properties set to load from

add

public void add(File f)
Add a file to the list

Parameters:
f - The file to add

remove

public void remove(File f)
Remove a file from the list

Parameters:
f - Remove a file from the list

add

public void add(String name)
Add a file to the list

Parameters:
name - The name of the file to add

remove

public void remove(String name)
Remove a file from the list

Parameters:
name - The name of the file to remove

buildMenu

public void buildMenu(JMenu menu)
Adds the recent file list to a menu. The files will be added at the end of the menu, with a separator before the files (if there are >0 files in the list)



Copyright © 2000-2013 FreeHEP. All Rights Reserved.