Example usage for com.jgoodies.looks FontPolicies createFixedPolicy

List of usage examples for com.jgoodies.looks FontPolicies createFixedPolicy

Introduction

In this page you can find the example usage for com.jgoodies.looks FontPolicies createFixedPolicy.

Prototype

public static FontPolicy createFixedPolicy(FontSet fontSet) 

Source Link

Document

Returns a font policy that in turn always returns the specified FontSet.

Usage

From source file:br.arthur.temp.tests.JCalendarDemo.java

License:Open Source License

/**
 * Installs the JGoodies Look & Feels, if available, in classpath.
 *///from  w w w  . j  a  va2 s.c  o m
public final void initializeLookAndFeels() {
    // if in classpath thry to load JGoodies Plastic Look & Feel
    try {
        LookAndFeelInfo[] lnfs = UIManager.getInstalledLookAndFeels();
        boolean found = false;
        for (int i = 0; i < lnfs.length; i++) {
            if (lnfs[i].getName().equals("JGoodies Plastic 3D")) {
                found = true;
            }
        }
        if (!found) {
            UIManager.installLookAndFeel("JGoodies Plastic 3D",
                    "com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
        }
        String os = System.getProperty("os.name");
        FontSet fontSet = null;
        if (os.startsWith("Windows")) {
            fontSet = FontSets.createDefaultFontSet(new Font("arial unicode MS", Font.PLAIN, 12));
        } else {
            fontSet = FontSets.createDefaultFontSet(new Font("arial unicode", Font.PLAIN, 12));
        }
        FontPolicy fixedPolicy = FontPolicies.createFixedPolicy(fontSet);
        PlasticLookAndFeel.setFontPolicy(fixedPolicy);

        UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
    } catch (Throwable t) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:com.jtstand.swing.MainFrame.java

License:Open Source License

public static void setLookAndFeel() {
    try {/*from  ww w  .  ja  v  a  2 s  . c  om*/
        //            String crosslaf = UIManager.getCrossPlatformLookAndFeelClassName();
        //            System.out.println("Cross Platfowm Look & Feel:" + crosslaf);

        String systemlaf = UIManager.getSystemLookAndFeelClassName();
        //            System.out.println("System Look & Feel:" + systemlaf);

        String nimbus = null;
        String windows = null;
        LookAndFeelInfo[] lafis = UIManager.getInstalledLookAndFeels();
        log.info("Installed Look & Feels:");
        for (int i = 0; i < lafis.length; i++) {
            LookAndFeelInfo lafi = lafis[i];
            String name = lafi.getName();
            log.info("[" + i + "]=" + name);
            if ("Nimbus".equals(name)) {
                nimbus = lafi.getClassName();
            } else if ("Windows".equals(name)) {
                windows = lafi.getClassName();
            }
        }

        //            if (windows != null) {
        //                UIManager.setLookAndFeel(windows);
        //                return;
        //            }
        UIManager.put(Options.USE_SYSTEM_FONTS_APP_KEY, Boolean.TRUE);

        FontSet fontSet = FontSets.createDefaultFontSet(
                //                    new Font("Tahoma", Font.PLAIN, 11), // control font
                //                    new Font("Tahoma", Font.PLAIN, 11), // menu font
                //                    new Font("Tahoma", Font.PLAIN, 11) // title font
                //                    new Font("Sans", Font.PLAIN, 11), // control font
                //                    new Font("Sans", Font.PLAIN, 11), // menu font
                //                    new Font("Sans", Font.PLAIN, 11) // title font
                new Font("Verdana", Font.PLAIN, 12), // control font
                new Font("Verdana", Font.PLAIN, 12), // menu font
                new Font("Verdana", Font.PLAIN, 12) // title font
        );
        FontPolicy fixedPolicy = FontPolicies.createFixedPolicy(fontSet);
        PlasticXPLookAndFeel.setFontPolicy(fixedPolicy);
        UIManager.setLookAndFeel(new PlasticXPLookAndFeel());

        //            System.out.println("getControlTextFont:" + PlasticXPLookAndFeel.getControlTextFont());
        //            System.out.println("getTitleTextFont:" + PlasticXPLookAndFeel.getTitleTextFont());
        //            System.out.println("getMenuTextFont:" + PlasticXPLookAndFeel.getMenuTextFont());
        //            System.out.println("getPlasticTheme:" + PlasticXPLookAndFeel.getPlasticTheme());

        //            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        //UIManager.setLookAndFeel(systemlaf);

    } catch (Exception ex) {
        log.error("Exception", ex);
    }
}