![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e904. Listening for Changes to the Current Directory in a JFileChooser Dialogfinal JFileChooser chooser = new JFileChooser(); // Add listener on chooser to detect changes to current directory chooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(evt.getPropertyName())) { JFileChooser chooser = (JFileChooser)evt.getSource(); File oldDir = (File)evt.getOldValue(); File newDir = (File)evt.getNewValue(); // The current directory should always be the same as newDir File curDir = chooser.getCurrentDirectory(); } } }) ;
e905. Listening for Approve and Cancel Events in a JFileChooser Dialog
© 2002 Addison-Wesley. |