Package jam.framework
Class RecentFileList
- java.lang.Object
-
- jam.framework.RecentFileList
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.util.EventListener
public class RecentFileList extends java.lang.Object implements java.awt.event.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 Summary
Constructors Constructor Description RecentFileList()
Create a RecentFileListRecentFileList(int size)
Create a RecentFileList with a given maximum lengthRecentFileList(java.lang.String type)
Create a recent file list.RecentFileList(java.lang.String type, int size)
Create a recent file list with a given type and size
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
void
add(java.io.File f)
Add a file to the listvoid
add(java.lang.String name)
Add a file to the listvoid
addActionListener(java.awt.event.ActionListener l)
void
buildMenu(javax.swing.JMenu menu)
Adds the recent file list to a menu.void
load(java.util.Properties props)
Load the recent file list from a Properties setvoid
remove(java.io.File f)
Remove a file from the listvoid
remove(java.lang.String name)
Remove a file from the listvoid
removeActionListener(java.awt.event.ActionListener l)
void
save(java.util.Properties props)
Save the recent file list in a Properties set
-
-
-
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(java.lang.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(java.lang.String type, int size)
Create a recent file list with a given type and size- Parameters:
type
- The prefix to usesize
- the maximum number of files to remember
-
-
Method Detail
-
addActionListener
public void addActionListener(java.awt.event.ActionListener l)
-
removeActionListener
public void removeActionListener(java.awt.event.ActionListener l)
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
save
public void save(java.util.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(java.util.Properties props)
Load the recent file list from a Properties set- Parameters:
props
- The Properties set to load from
-
add
public void add(java.io.File f)
Add a file to the list- Parameters:
f
- The file to add
-
remove
public void remove(java.io.File f)
Remove a file from the list- Parameters:
f
- Remove a file from the list
-
add
public void add(java.lang.String name)
Add a file to the list- Parameters:
name
- The name of the file to add
-
remove
public void remove(java.lang.String name)
Remove a file from the list- Parameters:
name
- The name of the file to remove
-
buildMenu
public void buildMenu(javax.swing.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)
-
-