![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e900. Displaying the Current Directory in the Title of a JFileChooser DialogThis example displays the complete path of the current directory in the title whenever the current directory changes.final JFileChooser chooser = new JFileChooser(); // Initialize title with current directory File curDir = chooser.getCurrentDirectory(); chooser.setDialogTitle(""+curDir.getAbsolutePath()); // 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())) { File curDir = chooser.getCurrentDirectory(); chooser.setDialogTitle(""+curDir.getAbsolutePath()); } } }) ;
e899. Setting an Accessory Component in a JFileChooser Dialog
© 2002 Addison-Wesley. |