Search in sources :

Example 11 with MetalLookAndFeel

use of javax.swing.plaf.metal.MetalLookAndFeel in project intellij-community by JetBrains.

the class DarculaLaf method getDefaults.

@Override
public UIDefaults getDefaults() {
    try {
        final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
        superMethod.setAccessible(true);
        final UIDefaults metalDefaults = (UIDefaults) superMethod.invoke(new MetalLookAndFeel());
        final UIDefaults defaults = (UIDefaults) superMethod.invoke(base);
        if (SystemInfo.isLinux) {
            if (!Registry.is("darcula.use.native.fonts.on.linux")) {
                Font font = findFont("DejaVu Sans");
                if (font != null) {
                    for (Object key : defaults.keySet()) {
                        if (key instanceof String && ((String) key).endsWith(".font")) {
                            defaults.put(key, new FontUIResource(font.deriveFont(13f)));
                        }
                    }
                }
            } else if (Arrays.asList("CN", "JP", "KR", "TW").contains(Locale.getDefault().getCountry())) {
                for (Object key : defaults.keySet()) {
                    if (key instanceof String && ((String) key).endsWith(".font")) {
                        final Font font = defaults.getFont(key);
                        if (font != null) {
                            defaults.put(key, new FontUIResource("Dialog", font.getStyle(), font.getSize()));
                        }
                    }
                }
            }
        }
        LafManagerImpl.initInputMapDefaults(defaults);
        initIdeaDefaults(defaults);
        patchStyledEditorKit(defaults);
        patchComboBox(metalDefaults, defaults);
        defaults.remove("Spinner.arrowButtonBorder");
        defaults.put("Spinner.arrowButtonSize", JBUI.size(16, 5).asUIResource());
        MetalLookAndFeel.setCurrentTheme(createMetalTheme());
        if (SystemInfo.isWindows && Registry.is("ide.win.frame.decoration")) {
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
        }
        if (SystemInfo.isLinux && JBUI.isUsrHiDPI()) {
            applySystemFonts(defaults);
        }
        defaults.put("EditorPane.font", defaults.getFont("TextField.font"));
        if (SystemInfo.isMacOSYosemite) {
            installMacOSXFonts(defaults);
        }
        return defaults;
    } catch (Exception e) {
        log(e);
    }
    return super.getDefaults();
}
Also used : FontUIResource(javax.swing.plaf.FontUIResource) Method(java.lang.reflect.Method) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) IOException(java.io.IOException)

Example 12 with MetalLookAndFeel

use of javax.swing.plaf.metal.MetalLookAndFeel 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 13 with MetalLookAndFeel

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

the class TestDialog method main.

// Not sure about what happens if multiple of this test are
//  instantiated in the same VM.  Being static (and using
//  static vars), it aint gonna work.  Not worrying about
//  it for now.
public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new MetalLookAndFeel());
    mainThread = Thread.currentThread();
    try {
        init();
    } catch (TestPassedException e) {
        // interepret this return as a pass
        return;
    }
    // called pass() or fail()
    try {
        Thread.sleep(sleepTime);
        //Timed out, so fail the test
        throw new RuntimeException("Timed out after " + sleepTime / 1000 + " seconds");
    } catch (InterruptedException e) {
        // so that the harness gets it and deals with it.
        if (!testGeneratedInterrupt)
            throw e;
        //reset flag in case hit this code more than once for some reason (just safety)
        testGeneratedInterrupt = false;
        if (theTestPassed == false) {
            throw new RuntimeException(failureMessage);
        }
    }
}
Also used : MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Example 14 with MetalLookAndFeel

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

the class bug7123767 method main.

public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new MetalLookAndFeel());
    setUp();
    testToolTip();
    TestFactory.uninstall();
    if (frame != null) {
        frame.dispose();
    }
}
Also used : MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Example 15 with MetalLookAndFeel

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

the class bug6777378 method main.

public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Robot robot = new Robot();
    robot.setAutoDelay(20);
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            try {
                UIManager.setLookAndFeel(new MetalLookAndFeel());
            } catch (Exception e) {
                e.printStackTrace();
            }
            JTable table = new JTable(new AbstractTableModel() {

                public int getRowCount() {
                    return 10;
                }

                public int getColumnCount() {
                    return 10;
                }

                public Object getValueAt(int rowIndex, int columnIndex) {
                    return "" + rowIndex + " " + columnIndex;
                }
            });
            header = new JTableHeader(table.getColumnModel());
            header.setToolTipText("hello");
            frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(header);
            frame.setSize(300, 300);
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    Point point = header.getLocationOnScreen();
    robot.mouseMove(point.x + 20, point.y + 50);
    robot.mouseMove(point.x + 30, point.y + 50);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
Also used : SunToolkit(sun.awt.SunToolkit) JTableHeader(javax.swing.table.JTableHeader) AbstractTableModel(javax.swing.table.AbstractTableModel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Aggregations

MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)18 LookAndFeel (javax.swing.LookAndFeel)3 MetalTheme (javax.swing.plaf.metal.MetalTheme)3 ValueNamePair (org.compiere.util.ValueNamePair)3 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)2 AppContext (sun.awt.AppContext)2 SunToolkit (sun.awt.SunToolkit)2 DarculaLaf (com.intellij.ide.ui.laf.darcula.DarculaLaf)1 File (java.io.File)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Charset (java.nio.charset.Charset)1 Level (java.util.logging.Level)1 Preferences (java.util.prefs.Preferences)1 JFrame (javax.swing.JFrame)1 UIDefaults (javax.swing.UIDefaults)1 FontUIResource (javax.swing.plaf.FontUIResource)1 DefaultMetalTheme (javax.swing.plaf.metal.DefaultMetalTheme)1