Java Swing Look and Feel initLookAndFeel()

Here you can find the source of initLookAndFeel()

Description

init Look And Feel

License

Open Source License

Declaration

public static void initLookAndFeel() 

Method Source Code


//package com.java2s;
/*   FILE: Utils.java/*from   w w  w  .j a v a 2s.c o m*/
 *   DATE OF CREATION:   Thu Jan 09 14:14:35 2003
 *   Copyright (c) Emmanuel Pietriga, 2002-2011. All Rights Reserved
 *   Licensed under the GNU LGPL. For full terms see the file COPYING.
 *
 * $Id: Utils.java 4942 2013-02-21 17:26:22Z epietrig $
 */

import java.awt.Font;

import java.util.Enumeration;
import javax.swing.UIManager;

public class Main {
    static Font smallFont = new Font("Dialog", 0, 10);
    static java.awt.Color pastelBlue = new java.awt.Color(156, 154, 206);

    public static void initLookAndFeel() {
        //  try {UIManager.setLookAndFeel(currentLookAndFeel);}
        //  catch(Exception ex){System.err.println("An error occured while trying to change the look and feel\n"+ex);}
        String key;
        Object okey;
        for (Enumeration e = UIManager.getLookAndFeelDefaults().keys(); e.hasMoreElements();) {
            okey = e.nextElement(); // depending on JVM (1.5.x and earlier, or 1.6.x or later) and OS,
            key = okey.toString(); // keys are respectively String or StringBuffer objects
            if (key.endsWith(".font") || key.endsWith("Font")) {
                UIManager.put(okey, smallFont);
            }
        }
        UIManager.put("ProgressBar.foreground", pastelBlue);
        UIManager.put("ProgressBar.background", java.awt.Color.lightGray);
        UIManager.put("Label.foreground", java.awt.Color.black);
    }
}

Related

  1. getNimbusLAF()
  2. getSortedInstalledLAFInfos()
  3. getSysDefLookandFeel()
  4. getSystemLAF()
  5. initLookAndFeel()
  6. initLookAndFeel(final String className)
  7. initLookAndFeelIntern(final String className)
  8. installLookAndFeel()
  9. isAqua()