Search in sources :

Example 1 with DarculaLaf

use of com.intellij.ide.ui.laf.darcula.DarculaLaf in project intellij-community by JetBrains.

the class DarculaTest method main.

public static void main(String[] args) {
    try {
        UIManager.setLookAndFeel(new DarculaLaf());
    } catch (UnsupportedLookAndFeelException ignored) {
    }
    final JFrame frame = new JFrame("Darcula Demo");
    frame.setSize(900, 500);
    final DarculaTest form = new DarculaTest();
    final JPanel root = form.myRoot;
    frame.setContentPane(root);
    frame.getRootPane().setDefaultButton(form.myDefaultButton);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {

        @Override
        public void eventDispatched(AWTEvent event) {
            if (event instanceof KeyEvent && event.getID() == KeyEvent.KEY_PRESSED && ((KeyEvent) event).getKeyCode() == KeyEvent.VK_F1) {
                new ShowUIDefaultsAction().actionPerformed(null);
            }
        }
    }, AWTEvent.KEY_EVENT_MASK);
    SwingUtilities.invokeLater(() -> frame.setVisible(true));
}
Also used : DarculaLaf(com.intellij.ide.ui.laf.darcula.DarculaLaf) KeyEvent(java.awt.event.KeyEvent) ShowUIDefaultsAction(com.intellij.ui.ShowUIDefaultsAction) AWTEventListener(java.awt.event.AWTEventListener)

Example 2 with DarculaLaf

use of com.intellij.ide.ui.laf.darcula.DarculaLaf in project android by JetBrains.

the class VisualTestsDialog method setDarculaMode.

private void setDarculaMode(boolean isDarcula) {
    try {
        if (isDarcula) {
            UIManager.setLookAndFeel(new DarculaLaf());
        } else {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
        JBColor.setDark(isDarcula);
        resetTabs();
        setUpdateMode(updateCheckbox.isSelected());
        setDebugMode(debugCheckbox.isSelected());
    } catch (Exception ignored) {
    }
}
Also used : DarculaLaf(com.intellij.ide.ui.laf.darcula.DarculaLaf)

Example 3 with DarculaLaf

use of com.intellij.ide.ui.laf.darcula.DarculaLaf 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)

Aggregations

DarculaLaf (com.intellij.ide.ui.laf.darcula.DarculaLaf)3 ShowUIDefaultsAction (com.intellij.ui.ShowUIDefaultsAction)1 AWTEventListener (java.awt.event.AWTEventListener)1 KeyEvent (java.awt.event.KeyEvent)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 DefaultMetalTheme (javax.swing.plaf.metal.DefaultMetalTheme)1 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)1 SynthLookAndFeel (javax.swing.plaf.synth.SynthLookAndFeel)1