• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

How can I found paths to "My Computer", "Desktop", ... folders for the current user?

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Couldn't you just check to see if you're running on a windows system and then add them in if applicable?
    Bookmark Topic Watch Topic
  • New Topic