WinXP SP3, Java 1.6.0_10-beta.
As I understood it, JFileChooser returns the directory whose contents are listed via getCurrentDirectory() and the file or directory selected in the list via getSelectedFile() (may be null). I've given this advice myself in the past.
[http://forums.sun.com/thread.jspa?threadID=5285236&start=2]
So has BoBear
[http://forums.sun.com/thread.jspa?threadID=5308380&start=3]
[http://forums.sun.com/thread.jspa?threadID=722884&start=5]
Well, it doesn't. Please run the code, which will display a JFileChooser 4 times and exit.
-- The first time, click the Open button without clicking elsewhere.
-- The second time, click on a folder (say Java) then click the open button
-- The third time, double-click a folder (say Java) to display its contents, then click the Open button
-- The fourth time, double click a folder (say Java) to display its contents, then click on a folder (say jre6), then click the open button.
This is the output I get:
Current directory set to: C:\Program Files
Selected file is: null
Current directory returned: C:\
Selected file returned: C:\Program Files
--------------------------
Current directory set to: C:\Program Files
Selected file is: null
Current directory returned: C:\Program Files
Selected file returned: C:\Program Files\Java
--------------------------
Current directory set to: C:\Program Files
Selected file is: null
Current directory returned: C:\Program Files
Selected file returned: C:\Program Files\Java
--------------------------
Current directory set to: C:\Program Files
Selected file is: null
Current directory returned: C:\Program Files\Java
Selected file returned: C:\Program Files\Java\jre6
--------------------------