javaswinguimanager

Java UIManager key list


I've seen people use UIManager to change strings of some pre-created swing components (e.g. JFileChooser).

Where can I find some kind of reference that will tell me which strings in which components are changeable, and how can I access them?

To clarify:

I know that UIManager.put(key, newString); will change text of string that key references to, to "newString".

Where can I find the list of keys?


Solution

  • These keys are provided by Swing PLAF resource bundles, and you can find them in the JDK sources. See e.g.:

    String values for languages other than English are provided by adjacent bundle files.

    And you can add one more bundle to any of these families just by creating one more file for desired human language and placing it anywhere on your classpath. Bundles in .java and .properties format work equally well, though .java format may be slightly more Unicode-friendly...

    It may be good to keep in mind though that direct adding of content to com.sun package may violate the Java license. So to be on the safe side, it may be wise to move your extra resources to a package of your own and register it with UIManager like this:

    UIManager.getDefaults().addResourceBundle("mypackage.swing.plaf.basic.resources.basic");