When you show only directories, and click on the dir icons to navigate, and then dont select anything and click OK, it automatically 'cd's to the parent folder.
My application is using the JFileChooser to let the user navigate through folders and certain details of 'foo' files in that folder are displayed in another panel.
So we dont want the chooser automatically changing dir to parent when OK is clicked. How to prevent this behavior?
I considered extending the chooser and looked at the Swing source code but it is hard to tell where the change dir is happening.
thanks,
Anil
To demonstrate this, I took the standard JFileChooserDemo from the Sun tutorial and modified it adding these lines
// NEW line 45 in constructor
fc.addPropertyChangeListener((PropertyChangeListener) this);
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
/*
* NEW -
*
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void propertyChange(PropertyChangeEvent e) {
String prop = e.getPropertyName();
if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(prop)) {
System.out.println("DIRECTORY_CHANGED_PROPERTY");
File file = (File) e.getNewValue();
System.out.println("DIRECTORY:" + file.getPath());
}
}