Java UIManager Keyword List

I have seen people use the UIManager to change the strings of some pre-created swing components (like JFileChooser).

Where can I find some kind of link that will tell me which lines in which components can change, and how can I access them?

To clarify:

I know that UIManager.put(key, newString); will change the text of the string referenced by the keywords to "newString" .

Where can I find a list of keys?

+6
source share
3 answers

These keys are provided by the Swing PLAF Resource Packs and can be found in the JDK sources. See for example:

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

And you can add another package to any of these families by simply creating another file for the desired human language and placing it anywhere in your class. Bundles in the .java format and .properties work equally well, although the .java format may be slightly more convenient for Unicode ...

It may be useful to keep in mind that directly adding content to the com.sun package may violate the Java license. To be safe, it may be wise to move your additional resources to your own package and register it using the UIManager as follows:

 UIManager.getDefaults().addResourceBundle("mypackage.swing.plaf.basic.resources.basic"); 
+1
source
  • Keys for UIManage r are Look and Feel sensitive, meaning (for example) the value of Keys for Metal Look and Feel may be different when comparing the values ​​from System Look and Feel , notification, or Key missed too

  • use UIManager Default by @camickr

+4
source

It seems like you need to run the code to see all the keys. I know the question is about java, but the fastest way to get the keys is to run the groovy (or gradle) script:

 javax.swing.UIManager.getDefaults().keys().toList().toSorted().each {println it} 

Paste it into the file and call groovy keys.groovy or gradle -b keys.groovy , which tool is easier for you to get.

Without creating a file, it can also be executed using groovy. Just do:

 groovy -e "javax.swing.UIManager.getDefaults().keys().toList().toSorted().each {println it}" 
0
source

Source: https://habr.com/ru/post/925244/


All Articles