final 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();
}) ;

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.