Java Swing UIManager loadUIManager()

Here you can find the source of loadUIManager()

Description

load UI Manager

License

LGPL

Declaration

public static void loadUIManager() 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import javax.swing.*;
import javax.swing.UIManager.LookAndFeelInfo;

import java.awt.*;

import java.lang.reflect.Method;
import java.util.*;

public class Main {
    public static void loadUIManager() {
        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");

            try {

                try {
                    // We need to do this using dynamic class loading to avoid other platforms
                    // having to link to this class. If the Quaqua library is not on the classpath
                    // it simply won't be used.
                    Class<?> qm = Class.forName("ch.randelshofer.quaqua.QuaquaManager");
                    Method method = qm.getMethod("setExcludedUIs", Set.class);

                    Set<String> excludes = new HashSet<String>();
                    excludes.add("Button");
                    excludes.add("ToolBar");
                    method.invoke(null, excludes);

                } catch (Throwable e) {
                }// w  ww  .  ja v  a  2 s  . c  om

                //set the Quaqua Look and Feel in the UIManager
                UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");
                lafLoaded = true;

            } catch (Exception e) {

            }

            UIManager.put("SystemFont", new Font("Lucida Grande", Font.PLAIN, 13));
            UIManager.put("SmallSystemFont", new Font("Lucida Grande", Font.PLAIN, 11));
        }

        try {

            if (!lafLoaded) {
                if (isMac()) {
                    UIManager.setLookAndFeel("javax.swing.plaf.metal");
                } else {
                    try {
                        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                            if ("Nimbus".equals(info.getName())) {
                                UIManager.setLookAndFeel(info.getClassName());
                                break;
                            }
                        }
                    } catch (Exception e) {
                        // If Nimbus is not available, you can set the GUI to another look and feel.
                        UIManager.setLookAndFeel("javax.swing.plaf.metal");
                    }
                }
                //UIManager.getSystemLookAndFeelClassName());
            }
        } catch (Exception e) {
        }
    }

    public static boolean isMac() {
        return System.getProperty("os.name").toLowerCase().startsWith("mac");
    }
}

Related

  1. isFlat(String id)
  2. isMetalLnF()
  3. isMnemonicHidden()
  4. listUIResources(String res)
  5. loadPlasticLnF()
  6. makeNative()
  7. makeSplitpaneNice()
  8. makeToolbarNice()
  9. noAltBg()