An file chooser can notify other Beans of changes. Changes can be of two types:
Action events. These alert other Beans if the file chooser's action buttons (Open, Save, Cancel, or a custom button) have been pushed.
Property changes. These reflect the current state of the XFileChooser Bean. Other Beans can find out if, for example, the file chooser has a newly selected file or if its title bar has changed.
XFileChooser has two actions for which other Beans can register to listen with addActionListener(): CANCEL_SELECTION, if the Cancel button is pushed, and APPROVE_SELECTION, if the Open or Save (or custom) button is pushed.
Rather than listen for events on these buttons, however, an application can simply bring up a file chooser and then check its return status using one of XFileChooser's properties:
Xfilechooser xfc = new XFileChooser; retval = xfc.show{Open,Save}Dialog(this); if (retval == xfc.APPROVE_OPTION) // open or save or whatever ...
Other Beans can listen to events in the file chooser by using the addPropertyChangeListener() method.
public MyListener(XFileChooser xfc) { xfc.addPropertyChangeListener(this); new PropertyChangeEvent e; if e.getPropertyName() == xfc.SELECTED_XFILE_PROPERTY_CHANGED { do_something(); ...
Most of the properties in XFileChooser are inherited from JFileChooser, so you should refer to thejavadocs of the JFileChooser for a complete list of JFileChooser fields. Properties that can be changed through the XFileChooser Bean's property sheet (in a Bean-aware editor) are listed in "XFileChooser is a Bean".
XFileChooser does have three variables unique to itself, however:
SELECTED_XFILE_CHANGED_PROPERTY
Equivalent to SELECTED_FILE_CHANGED_PROPERTY in JFileChooser. Indicates that a user has changed a single-file selection.
SELECTED_XFILES_CHANGED_PROPERTY
Equivalent to SELECTED_FILES_CHANGED_PROPERTY. Indicates that a user has changed the selection of multiple files.
XDIRECTORY_CHANGED_PROPERTY
Equivalent to DIRECTORY_CHANGED_PROPERTY. Indicates that the user has changed the working directory.