Java JFileChooser class

2 replies [Last post]
Offline
Joined: Dec 20 2003
Posts: 89

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

__________________

Happy Birthday QuickTime!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Offline
Joined: Dec 20 2003
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?

__________________

Happy Birthday QuickTime!

sourapple's picture
Offline
Joined: May 27 2004
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.

__________________

http://www.applemachome.com