|
e900. Displaying the Current Directory in the Title of a JFileChooser Dialog
This 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());
}
}
}) ;
e898.
Changing the Text of the Approve Button in a JFileChooser Dialog
e899.
Setting an Accessory Component in a JFileChooser Dialog
© 2002 Addison-Wesley.
|