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
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
Please support the defense of Ukraine.
Credit card, bank transfer
Bitcoin, Ethereum, Polkadot, USDT
via Unclutter App for Mac
No Ads.
No Trackers.
No Social Media.
All Content Locally Hosted.
40 Gigabytes and Growing.
Built on Free Software.
This page, the entire Applefritter site, and all subsites of are copyright 1999-2999 by Tom Owad unless otherwise noted. All rights reserved. Apple, the Apple logo, Macintosh, Mac, MacOS, MacBook, iMac, and Mac Pro are trademarks of Apple Computer, Inc. LEGO®is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this site (the feeling's mutual).
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?
because if you dont have an empty file object for it to put anything into it wont do nothing.