This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hello All. I want to create more useful file open/save dialog that uses JfileChooser. I want to add links to �Desktop�, �My Computer�, �My Documents�, �My Pictures� and so on like on open dialog in WinXp. How can I found paths to these folders for the current user?
You could... but you'd have to make the file chooser pretty much from scratch (or look at the code for JFileChooser and change it...), and then it would only be specific to Windows XP!
For example, on my Windows 2000 box here at work, most of these files are kept in C:\Documents and Settings\<username>, but I know that these are kept somewhere completely different on my Windows 98 box at home. And my linux box has no idea what "My Documents" are?!?!
The System class provides a platform independent way to get the user's home directory (System.getProperty( "user.home" )), but I would leave it up to the user to go to "My Documents", "My Pictures", etc. [ February 27, 2003: Message edited by: Nathan Pruett ]
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
on winxp and win2k you'd be safe saying this: String home = System.getProperty("user.home"); String myDocs = home + "/My Documents"; String desktop = home + "/Desktop"; as far as my computer, you're screwed. I'll re-inforce that you are losing all cross-platform capability here. Write the damn thing in VB.