Search in sources :

Example 1 with SubstanceLookAndFeel

use of org.pushingpixels.substance.api.SubstanceLookAndFeel 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 2 with SubstanceLookAndFeel

use of org.pushingpixels.substance.api.SubstanceLookAndFeel in project MtgDesktopCompanion by nicho92.

the class LookAndFeelProvider method getExtraLookAndFeel.

public LookAndFeelInfo[] getExtraLookAndFeel() {
    if (!list.isEmpty())
        return list.toArray(new LookAndFeelInfo[list.size()]);
    Reflections classReflections = new Reflections("org.pushingpixels.substance.api.skin");
    list = new ArrayList<>();
    for (Class<? extends SubstanceLookAndFeel> c : classReflections.getSubTypesOf(SubstanceLookAndFeel.class)) {
        try {
            SubstanceLookAndFeel look = c.getConstructor(null).newInstance();
            list.add(new LookAndFeelInfo(look.getID(), c.getName()));
        } catch (Exception e) {
            logger.error("Loading " + c, e);
        }
    }
    return list.toArray(new LookAndFeelInfo[list.size()]);
}
Also used : SubstanceLookAndFeel(org.pushingpixels.substance.api.SubstanceLookAndFeel) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) Reflections(org.reflections.Reflections)

Aggregations

SubstanceLookAndFeel (org.pushingpixels.substance.api.SubstanceLookAndFeel)2 Preferences (java.util.prefs.Preferences)1 JMenu (javax.swing.JMenu)1 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)1 LookAndFeel (javax.swing.LookAndFeel)1 LookAndFeelInfo (javax.swing.UIManager.LookAndFeelInfo)1 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)1 NimbusLookAndFeel (javax.swing.plaf.nimbus.NimbusLookAndFeel)1 SkinInfo (org.pushingpixels.substance.api.skin.SkinInfo)1 Reflections (org.reflections.Reflections)1