Search in sources :

Example 6 with MetalTheme

use of javax.swing.plaf.metal.MetalTheme in project jgnash by ccavanaugh.

the class ThemeManager method buildThemeMenu.

JMenu buildThemeMenu() {
    Preferences pref = Preferences.userNodeForPackage(ThemeManager.class);
    String currentTheme = pref.get(THEME, DEFAULT_THEME);
    themesMenu = new JMenu();
    themesMenu.setText(rb.getString("Menu.Themes.Name"));
    ButtonGroup themeButtonGroup = new ButtonGroup();
    buildThemeList();
    JRadioButtonMenuItem button;
    for (Object aThemeList : themeList) {
        MetalTheme theme = (MetalTheme) aThemeList;
        button = new JRadioButtonMenuItem();
        button.setText(theme.getName());
        button.setActionCommand(theme.getClass().getName());
        button.addActionListener(e -> {
            Preferences pref1 = Preferences.userNodeForPackage(ThemeManager.class);
            pref1.put(THEME, e.getActionCommand());
            restartUI();
        });
        themeButtonGroup.add(button);
        themesMenu.add(button);
        if (aThemeList.getClass().getName().equals(currentTheme)) {
            button.setSelected(true);
        }
    }
    refreshThemesState();
    return themesMenu;
}
Also used : ButtonGroup(javax.swing.ButtonGroup) MetalTheme(javax.swing.plaf.metal.MetalTheme) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) Preferences(java.util.prefs.Preferences) JMenu(javax.swing.JMenu)

Example 7 with MetalTheme

use of javax.swing.plaf.metal.MetalTheme in project adempiere by adempiere.

the class PLAFEditor method setLFSelection.

//  dynInit
/**
	 *  Set Picks From Environment
	 */
private void setLFSelection() {
    m_setting = true;
    //  Search for PLAF
    ValueNamePair plaf = null;
    LookAndFeel lookFeel = UIManager.getLookAndFeel();
    String look = lookFeel.getClass().getName();
    for (int i = 0; i < AdempierePLAF.getPLAFs().length; i++) {
        ValueNamePair vp = AdempierePLAF.getPLAFs()[i];
        if (vp.getValue().equals(look)) {
            plaf = vp;
            break;
        }
    }
    if (plaf != null)
        lfField.setSelectedItem(plaf);
    //  Search for Theme
    MetalTheme metalTheme = null;
    ValueNamePair theme = null;
    boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel;
    themeField.setModel(new DefaultComboBoxModel(AdempierePLAF.getThemes()));
    if (metal) {
        theme = null;
        AppContext context = AppContext.getAppContext();
        metalTheme = (MetalTheme) context.get("currentMetalTheme");
        if (metalTheme != null) {
            String lookTheme = metalTheme.getName();
            for (int i = 0; i < AdempierePLAF.getThemes().length; i++) {
                ValueNamePair vp = AdempierePLAF.getThemes()[i];
                if (vp.getName().equals(lookTheme)) {
                    theme = vp;
                    break;
                }
            }
        }
        if (theme != null)
            themeField.setSelectedItem(theme);
    }
    m_setting = false;
    log.info(lookFeel + " - " + metalTheme);
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme) AppContext(sun.awt.AppContext) ValueNamePair(org.compiere.util.ValueNamePair) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) LookAndFeel(javax.swing.LookAndFeel) CompiereLookAndFeel(org.compiere.plaf.CompiereLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Example 8 with MetalTheme

use of javax.swing.plaf.metal.MetalTheme in project adempiere by adempiere.

the class PreviewPanel method lookAndFeelSelectionChanged.

/**
	 * Handle look and feel selection changed
	 * @param e
	 */
protected void lookAndFeelSelectionChanged(ListSelectionEvent e) {
    if (m_setting)
        return;
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    ValueNamePair laf = (ValueNamePair) lookList.getSelectedValue();
    LookAndFeel currentLaf = UIManager.getLookAndFeel();
    MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme();
    AdempierePLAF.setPLAF(laf, null, false);
    previewPanel.refresh(currentLaf, currentTheme);
    SwingUtilities.updateComponentTreeUI(previewPanel);
    updatePreviewComponents();
    setLFSelection();
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    this.repaint();
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme) ValueNamePair(org.compiere.util.ValueNamePair) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) LookAndFeel(javax.swing.LookAndFeel)

Example 9 with MetalTheme

use of javax.swing.plaf.metal.MetalTheme in project adempiere by adempiere.

the class PreviewPanel method themeSelectionChanged.

/**
	 * Handle theme selection changed
	 * @param e
	 */
protected void themeSelectionChanged(ListSelectionEvent e) {
    if (m_setting)
        return;
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    ValueNamePair laf = (ValueNamePair) lookList.getSelectedValue();
    ValueNamePair theme = (ValueNamePair) themeList.getSelectedValue();
    LookAndFeel currentLaf = UIManager.getLookAndFeel();
    MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme();
    AdempierePLAF.setPLAF(laf, theme, false);
    previewPanel.refresh(currentLaf, currentTheme);
    SwingUtilities.updateComponentTreeUI(previewPanel);
    updatePreviewComponents();
    setLFSelection();
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    this.repaint();
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme) ValueNamePair(org.compiere.util.ValueNamePair) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) LookAndFeel(javax.swing.LookAndFeel)

Example 10 with MetalTheme

use of javax.swing.plaf.metal.MetalTheme in project jdk8u_jdk by JetBrains.

the class MetalThemeMenu method actionPerformed.

public void actionPerformed(ActionEvent e) {
    String numStr = e.getActionCommand();
    MetalTheme selectedTheme = themes[Integer.parseInt(numStr)];
    MetalLookAndFeel.setCurrentTheme(selectedTheme);
    try {
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (Exception ex) {
        System.out.println("Failed loading Metal");
        System.out.println(ex);
    }
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme)

Aggregations

MetalTheme (javax.swing.plaf.metal.MetalTheme)10 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)5 ValueNamePair (org.compiere.util.ValueNamePair)5 LookAndFeel (javax.swing.LookAndFeel)4 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 JMenu (javax.swing.JMenu)2 AppContext (sun.awt.AppContext)2 PlasticTheme (com.jgoodies.looks.plastic.PlasticTheme)1 InputStream (java.io.InputStream)1 Charset (java.nio.charset.Charset)1 Level (java.util.logging.Level)1 Preferences (java.util.prefs.Preferences)1 ButtonGroup (javax.swing.ButtonGroup)1 JMenuBar (javax.swing.JMenuBar)1 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)1 DefaultMetalTheme (javax.swing.plaf.metal.DefaultMetalTheme)1 OceanTheme (javax.swing.plaf.metal.OceanTheme)1 CompiereLookAndFeel (org.compiere.plaf.CompiereLookAndFeel)1