use of javax.swing.plaf.metal.DefaultMetalTheme in project jdk8u_jdk by JetBrains.
the class bug6742358 method main.
public static void main(String[] args) {
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
JFrame frame = new JFrame();
frame.setContentPane(new TestPanel());
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
use of javax.swing.plaf.metal.DefaultMetalTheme in project jdk8u_jdk by JetBrains.
the class MetalworksFrame method buildMenus.
protected void buildMenus() {
menuBar = new JMenuBar();
menuBar.setOpaque(true);
JMenu file = buildFileMenu();
JMenu edit = buildEditMenu();
JMenu views = buildViewsMenu();
JMenu speed = buildSpeedMenu();
JMenu help = buildHelpMenu();
// load a theme from a text file
MetalTheme myTheme = null;
try {
InputStream istream = getClass().getResourceAsStream("/resources/MyTheme.theme");
myTheme = new PropertiesMetalTheme(istream);
} catch (NullPointerException e) {
System.out.println(e);
}
// build an array of themes
MetalTheme[] themes = { new OceanTheme(), new DefaultMetalTheme(), new GreenMetalTheme(), new AquaMetalTheme(), new KhakiMetalTheme(), new DemoMetalTheme(), new ContrastMetalTheme(), new BigContrastMetalTheme(), myTheme };
// put the themes in a menu
JMenu themeMenu = new MetalThemeMenu("Theme", themes);
menuBar.add(file);
menuBar.add(edit);
menuBar.add(views);
menuBar.add(themeMenu);
menuBar.add(speed);
menuBar.add(help);
setJMenuBar(menuBar);
}
use of javax.swing.plaf.metal.DefaultMetalTheme in project intellij-community by JetBrains.
the class LafManagerImpl method setCurrentLookAndFeel.
/**
* Sets current LAF. The method doesn't update component hierarchy.
*/
@Override
public void setCurrentLookAndFeel(UIManager.LookAndFeelInfo lookAndFeelInfo) {
if (findLaf(lookAndFeelInfo.getClassName()) == null) {
LOG.error("unknown LookAndFeel : " + lookAndFeelInfo);
return;
}
// Set L&F
if (IdeaLookAndFeelInfo.CLASS_NAME.equals(lookAndFeelInfo.getClassName())) {
// that is IDEA default LAF
IdeaLaf laf = new IdeaLaf();
MetalLookAndFeel.setCurrentTheme(new IdeaBlueMetalTheme());
try {
UIManager.setLookAndFeel(laf);
} catch (Exception e) {
Messages.showMessageDialog(IdeBundle.message("error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()), CommonBundle.getErrorTitle(), Messages.getErrorIcon());
return;
}
} else if (DarculaLookAndFeelInfo.CLASS_NAME.equals(lookAndFeelInfo.getClassName())) {
DarculaLaf laf = new DarculaLaf();
try {
UIManager.setLookAndFeel(laf);
JBColor.setDark(true);
IconLoader.setUseDarkIcons(true);
} catch (Exception e) {
Messages.showMessageDialog(IdeBundle.message("error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()), CommonBundle.getErrorTitle(), Messages.getErrorIcon());
return;
}
} else {
// non default LAF
try {
LookAndFeel laf = ((LookAndFeel) Class.forName(lookAndFeelInfo.getClassName()).newInstance());
if (laf instanceof MetalLookAndFeel) {
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
}
UIManager.setLookAndFeel(laf);
} catch (Exception e) {
Messages.showMessageDialog(IdeBundle.message("error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()), CommonBundle.getErrorTitle(), Messages.getErrorIcon());
return;
}
}
myCurrentLaf = ObjectUtils.chooseNotNull(findLaf(lookAndFeelInfo.getClassName()), lookAndFeelInfo);
checkLookAndFeel(lookAndFeelInfo, false);
}
use of javax.swing.plaf.metal.DefaultMetalTheme in project jdk8u_jdk by JetBrains.
the class bug6742358 method init.
public void init() {
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
TestPanel panel = new TestPanel();
setContentPane(panel);
}
Aggregations