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;
}
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);
}
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();
}
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();
}
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);
}
}
Aggregations