WebNFS Developer's Guide

Events

An file chooser can notify other Beans of changes. Changes can be of two types:

Action Events

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 ...

Properties

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: