load Look And Feel - Java Swing

Java examples for Swing:Look and Feel

Description

load Look And Feel

Demo Code

/**/*from   w  ww .j a  va 2s  .  co  m*/
 * JFrameUtils
 * Created by Lu?s F. Loureiro, github.com/nczeroshift
 * Under MIT license
 */
import javax.swing.*;
import javax.swing.UIManager.LookAndFeelInfo;
import java.awt.*;
import java.io.File;
import java.io.InputStream;

public class Main{
    public static void loadLookAndFeel() {
        InputStream fntVera = JFrameUtils.class
                .getResourceAsStream("/org/nczeroshift/fonts/VeraMono.ttf");

        try {
            GraphicsEnvironment ge = GraphicsEnvironment
                    .getLocalGraphicsEnvironment();
            ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, fntVera));
        } catch (Exception e) {
            e.printStackTrace();
            //Handle exception
        }

        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"
                    .equals(info.getClassName())) {
                try {
                    UIManager.setLookAndFeel(info.getClassName());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;
            }
        }
    }
}

Related Tutorials