Java JFileChooser class

3 posts / 0 new
Last post
Offline
Last seen: 17 years 4 months ago
Joined: Dec 20 2003 - 10:38
Posts: 89
Java JFileChooser class

I'm fighting my way through learning Java, and my prof hasn't fully picked it up yet. When I use a JFileChooser object to allow users to open a file, how do I tell it to start at the same directory the program is stored in?

Thanks

Offline
Last seen: 17 years 4 months ago
Joined: Dec 20 2003 - 10:38
Posts: 89
Done and Done!

You use the setCurrentDirectory() method.

Example:
JFileChooser jFileChooser = new JFileChooser;
jFileChooser.setCurrentDirectory (new File ("."));

It looks like you just pass it a new file object, anyone know why this works?

sourapple's picture
Offline
Last seen: 15 years 10 months ago
Joined: May 27 2004 - 02:42
Posts: 209
because if you dont have an e

because if you dont have an empty file object for it to put anything into it wont do nothing.

Log in or register to post comments