• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Swing save dialog

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
I am not young enough to know everything. - Oscar Wilde This tiny ad thinks it knows more than Oscar:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic