Package jam.framework

Class RecentFileList

java.lang.Object
jam.framework.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 183 2006-01-23 21:29:48Z rambaut $
Author:
Tony Johnson (tonyj@slac.stanford.edu)
  • Constructor Details

    • 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 Details

    • 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)