Search in sources :

Example 11 with LookAndFeel

use of javax.swing.LookAndFeel in project jgnash by ccavanaugh.

the class ThemeManager method buildSubstanceMenu.

private JMenu buildSubstanceMenu() {
    LookAndFeel lf = UIManager.getLookAndFeel();
    JMenu substanceMenu = new JMenu(rb.getString("Menu.SubstanceThemes.Name"));
    for (SkinInfo info : SubstanceLookAndFeel.getAllSkins().values()) {
        JRadioButtonMenuItem button = new JRadioButtonMenuItem();
        button.setText(info.getDisplayName());
        button.setActionCommand(info.getClassName());
        // add the button to the global look and feel
        lfButtonGroup.add(button);
        button.addActionListener(e -> {
            Preferences pref = Preferences.userNodeForPackage(ThemeManager.class);
            pref.put(LF, e.getActionCommand());
            restartUI();
        });
        substanceMenu.add(button);
        // select the button as the active L&F if it is the current skin
        if (lf instanceof SubstanceLookAndFeel) {
            if (SubstanceLookAndFeel.getCurrentSkin().getClass().getName().equals(info.getClassName())) {
                button.setSelected(true);
            }
        }
    }
    return substanceMenu;
}
Also used : SkinInfo(org.pushingpixels.substance.api.skin.SkinInfo) SubstanceLookAndFeel(org.pushingpixels.substance.api.SubstanceLookAndFeel) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) Preferences(java.util.prefs.Preferences) LookAndFeel(javax.swing.LookAndFeel) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel) SubstanceLookAndFeel(org.pushingpixels.substance.api.SubstanceLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) JMenu(javax.swing.JMenu)

Example 12 with LookAndFeel

use of javax.swing.LookAndFeel in project jgnash by ccavanaugh.

the class ThemeManager method isLookAndFeelAvailable.

/**
     * A utility function that layers on top of the LookAndFeel's
     * isSupportedLookAndFeel() method. Returns true if the LookAndFeel is
     * supported. Returns false if the LookAndFeel is not supported and/or if
     * there is any kind of error checking if the LookAndFeel is supported.
     * <p>
     * The Look and Feel menu will use this method to determine whether the various Look and Feel
     * options should be active or inactive.
     * 
     * @param laf name of look and feel to search for
     * @return true if found
     */
@SuppressWarnings("rawtypes")
private static boolean isLookAndFeelAvailable(final String laf) {
    try {
        Class lnfClass = Class.forName(laf);
        LookAndFeel newLAF = (LookAndFeel) lnfClass.newInstance();
        return newLAF.isSupportedLookAndFeel();
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
        // If ANYTHING bad happens, return false
        Logger.getLogger(ThemeManager.class.getName()).log(Level.FINEST, e.getLocalizedMessage(), e);
        return false;
    }
}
Also used : LookAndFeel(javax.swing.LookAndFeel) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel) SubstanceLookAndFeel(org.pushingpixels.substance.api.SubstanceLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Example 13 with LookAndFeel

use of javax.swing.LookAndFeel in project jgnash by ccavanaugh.

the class ThemeManager method setLookAndFeel.

private static void setLookAndFeel(final String lookAndFeel) {
    Preferences pref = Preferences.userNodeForPackage(ThemeManager.class);
    String theme = pref.get(THEME, DEFAULT_THEME);
    try {
        Class<?> lafClass = Class.forName(lookAndFeel);
        Object lafInstance = lafClass.newInstance();
        if (lafInstance instanceof SubstanceSkin) {
            UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS, Boolean.TRUE);
            if (isSubstanceAnimationsEnabled()) {
                AnimationConfigurationManager.getInstance().setTimelineDuration(animationDuration);
            } else {
                AnimationConfigurationManager.getInstance().setTimelineDuration(0);
            }
            SubstanceLookAndFeel.setSkin(lookAndFeel);
        } else if (lafInstance instanceof NimbusLookAndFeel) {
            UIManager.setLookAndFeel((LookAndFeel) lafInstance);
            NimbusUtils.changeFontSize(getNimbusFontSize());
        } else if (lafInstance instanceof MetalLookAndFeel) {
            UIManager.setLookAndFeel((LookAndFeel) lafInstance);
            setTheme(theme);
        } else if (lafInstance instanceof LookAndFeel) {
            UIManager.setLookAndFeel((LookAndFeel) lafInstance);
        }
    } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
        Logger.getLogger(ThemeManager.class.getName()).log(Level.WARNING, null, e);
    }
}
Also used : LookAndFeel(javax.swing.LookAndFeel) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel) SubstanceLookAndFeel(org.pushingpixels.substance.api.SubstanceLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) SubstanceSkin(org.pushingpixels.substance.api.SubstanceSkin) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel) Preferences(java.util.prefs.Preferences)

Example 14 with LookAndFeel

use of javax.swing.LookAndFeel in project 111mil-funes by cperezabo.

the class AgendaContactos method main.

public static void main(String[] args) {
    try {
        LookAndFeel laf = UIManager.getLookAndFeel();
        if ("Metal".equals(laf.getName())) {
            String className = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
            UIManager.setLookAndFeel(className);
        }
    } catch (Exception e) {
    //No importa
    }
    PantallaListadoContactos pantalla = new PantallaListadoContactos();
    pantalla.setVisible(true);
}
Also used : LookAndFeel(javax.swing.LookAndFeel)

Example 15 with LookAndFeel

use of javax.swing.LookAndFeel in project 111mil-funes by cperezabo.

the class Tateti method main.

public static void main(String[] args) {
    try {
        LookAndFeel laf = UIManager.getLookAndFeel();
        if ("Metal".equals(laf.getName())) {
            String className = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
            UIManager.setLookAndFeel(className);
        }
    } catch (Exception e) {
    //No importa
    }
    Tablero tablero = new Tablero();
    tablero.setVisible(true);
}
Also used : LookAndFeel(javax.swing.LookAndFeel)

Aggregations

LookAndFeel (javax.swing.LookAndFeel)15 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)9 NimbusLookAndFeel (javax.swing.plaf.nimbus.NimbusLookAndFeel)5 SubstanceLookAndFeel (org.pushingpixels.substance.api.SubstanceLookAndFeel)5 Preferences (java.util.prefs.Preferences)4 MetalTheme (javax.swing.plaf.metal.MetalTheme)4 ValueNamePair (org.compiere.util.ValueNamePair)4 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)3 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 JMenu (javax.swing.JMenu)2 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)2 AppContext (sun.awt.AppContext)2 PlasticLookAndFeel (com.jgoodies.looks.plastic.PlasticLookAndFeel)1 ExperienceBlue (com.jgoodies.looks.plastic.theme.ExperienceBlue)1 SkinLookAndFeel (com.l2fprod.gui.plaf.skin.SkinLookAndFeel)1 Color (java.awt.Color)1 InvalidDnDOperationException (java.awt.dnd.InvalidDnDOperationException)1 ArrayList (java.util.ArrayList)1 Icon (javax.swing.Icon)1 JTree (javax.swing.JTree)1