FileChooser - select only directories but still see files?

Is it possible to have a JFileChooser that, while only allowing a directory to be selected, still shows files in the text area?

If I set this:

fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

it indeed allows only directories to be selected, but I can't see files in the directory (which could indicate to the user if this is the directory they wanted)

[394 byte] By [allelopatha] at [2007-11-27 11:56:50]
# 1

Yes, but you have to hack the default behavior:

JFileChooser fc = new JFileChooser() {

public void approveSelection() {

File f = this.getSelectedFile();

if (f != null && f.isDirectory())

super.approveSelection();

}

};

fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

Jasprea at 2007-7-29 19:09:49 > top of Java-index,Desktop,Core GUI APIs...