Java Utililty Methods Swing UIManager

List of utility methods to do Swing UIManager

Description

The list of methods to do Swing UIManager are organized into topic(s).

Method

voidinstallDefaults()
Workaround for Bug#5063999.
String defaultlaf = System.getProperty("swing.defaultlaf");
if (defaultlaf == null || defaultlaf.length() == 0) {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | UnsupportedLookAndFeelException | IllegalAccessException
            | InstantiationException ex) {
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
UIManager.put(FORMATTED_TEXTFIELD_FONT_KEY, UIManager.get(TEXTFIELD_FONT_KEY));
UIManager.put(FORMATTED_TEXTFIELD_INACTIVE_BACKGROUND_KEY,
        UIManager.get(TEXTFIELD_INACTIVE_BACKGROUND_KEY));
UIManager.put(PASSWORDFIELD_FONT_KEY, UIManager.get(TEXTFIELD_FONT_KEY));
voidinstallGtkPopupBugWorkaround()
Swing menus are looking pretty bad on Linux when the GTK LaF is used (See bug #6925412).
LookAndFeel laf = UIManager.getLookAndFeel();
Class<?> lafClass = laf.getClass();
if (!lafClass.getName().equals("com.sun.java.swing.plaf.gtk.GTKLookAndFeel")) {
    return;
try {
    Field field = lafClass.getDeclaredField("styleFactory");
    boolean accessible = field.isAccessible();
...
voidinstallGtkPopupBugWorkaround()
Swing menus are looking pretty bad on Linux when the GTK LaF is used (See bug #6925412).
LookAndFeel laf = UIManager.getLookAndFeel();
Class<?> lafClass = laf.getClass();
if (!lafClass.getName().equals("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"))
    return;
try {
    Field field = lafClass.getDeclaredField("styleFactory");
    boolean accessible = field.isAccessible();
    field.setAccessible(true);
...
booleanisFlat(String id)
is Flat
return Boolean.TRUE.equals(UIManager.get(id + ".isFlat"));
booleanisMetalLnF()
Returns whether we're currently running the Metal Look&Feel.
return UIManager.getLookAndFeel().getID().equals("Metal");
booleanisMnemonicHidden()
Gets the state of the hide mnemonic flag.
if (UIManager.getBoolean("Button.showMnemonics") == true)
    isMnemonicHidden = false;
return isMnemonicHidden;
voidlistUIResources(String res)
list UI Resources
UIDefaults uid = UIManager.getLookAndFeelDefaults();
for (Enumeration e = uid.keys(); e.hasMoreElements();) {
    String s = (String) e.nextElement();
    if (s.indexOf(res ) != -1) {
        System.out.println(s + " <-> " + uid.get(s));
voidloadPlasticLnF()
load Plastic Ln F
try {
    UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
} catch (Exception e) {
voidloadUIManager()
load UI Manager
boolean lafLoaded = false;
if (isMac()) {
    System.setProperty("apple.awt.graphics.UseQuartz", "true");
    System.setProperty("apple.awt.antialiasing", "true");
    System.setProperty("apple.awt.rendering", "VALUE_RENDER_QUALITY");
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    System.setProperty("apple.awt.draggableWindowBackground", "true");
    System.setProperty("apple.awt.showGrowBox", "true");
...
voidmakeNative()
Attempts to set the current L&F to native, and perform appearance tweaks to mimic the current OS's L&F.
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Amber IDE");
System.setProperty("apple.awt.showGrowBox", "true");
System.setProperty("apple.awt.brushMetalLook", "true");
System.setProperty("sun.java2d.noddraw", "true");
System.setProperty("swing.aatext", "true");
JFrame.setDefaultLookAndFeelDecorated(false);
JDialog.setDefaultLookAndFeelDecorated(false);
...