• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing save dialog

 
Dave Smith
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I change some of the labels inside a JFileChooser? I am wanting to change labels such as the "Look in" label in the top left. Anyone have any ideas?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you saw methods like setApproveButtonText() and setDialogTitle(). Unfortunately there doesn't appear to be one for the "Look in" label. It appears that this is part of the metal look and feel. There's probably an easy way to do this, but I haven't found it yet, so I'll just share what I've learned so far:
I'd download a copy of the jdk source for 1.2.2 or 1.3 - I'm looking at 1.3. Search for "Look in" (no quotes) as contained text - there's a file src\share\classes\javax\swing\plaf\metal\resources\metal.properties which contains the strings used for labels by JFileChooser. I assume there's a copy of this file inside one of the jar files in the jdk. So now you need to figure out how to make your own custom look and feel, preferably by just overriding specific properties of the metal look and feel. I think this is as simple as using the UIManager.put() method:
UIManager.put("FileChooser.lookInLabelText", "Look in");
(put your own text in place of "Look in" of course.) You'll need to look at that metal.properties file to get a complete list of proerties you can set. (Well, there's probably also a way to make the machine print them out for you.)
Unfortunately, that's all I have time to figure out now. Good luck - and please let me know if it works, or if you find some other trick to accomplish what you need.
 
Dave Smith
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers, it does fetch the String, and can be set using the put (though I don't think it works to spec ). Where do I find all the atrtibutes of this dialogue?
Is it in the JDK source?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The source is where I found it, in the file I specified. Since the file is not compiled but rather read as is at runtime, it should be part of the jdk itself as well (i.e. not the source, but the final execuatable version). But I'm not sure where - it's probably in one of the various jar files. You can use the jar command to get a list of files in a jar, but I don't have time to track it down myself right now. Anyway, it's always fun to have a copy of the Java source lying around to look at. You can get it from http://www.sun.com/software/communitysource/java2/. Enjoy!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!