Search in sources :

Example 1 with DefaultMetalTheme

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);
}
Also used : DefaultMetalTheme(javax.swing.plaf.metal.DefaultMetalTheme)

Example 2 with DefaultMetalTheme

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);
}
Also used : InputStream(java.io.InputStream) DefaultMetalTheme(javax.swing.plaf.metal.DefaultMetalTheme) OceanTheme(javax.swing.plaf.metal.OceanTheme) DefaultMetalTheme(javax.swing.plaf.metal.DefaultMetalTheme) MetalTheme(javax.swing.plaf.metal.MetalTheme) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 3 with DefaultMetalTheme

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);
}
Also used : DarculaLaf(com.intellij.ide.ui.laf.darcula.DarculaLaf) SynthLookAndFeel(javax.swing.plaf.synth.SynthLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) InvocationTargetException(java.lang.reflect.InvocationTargetException) DefaultMetalTheme(javax.swing.plaf.metal.DefaultMetalTheme)

Example 4 with DefaultMetalTheme

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);
}
Also used : DefaultMetalTheme(javax.swing.plaf.metal.DefaultMetalTheme)

Aggregations

DefaultMetalTheme (javax.swing.plaf.metal.DefaultMetalTheme)4 DarculaLaf (com.intellij.ide.ui.laf.darcula.DarculaLaf)1 InputStream (java.io.InputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 JMenu (javax.swing.JMenu)1 JMenuBar (javax.swing.JMenuBar)1 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)1 MetalTheme (javax.swing.plaf.metal.MetalTheme)1 OceanTheme (javax.swing.plaf.metal.OceanTheme)1 SynthLookAndFeel (javax.swing.plaf.synth.SynthLookAndFeel)1