类javax.swing.plaf.metal.MetalLookAndFeel源码实例Demo

下面列出了怎么用javax.swing.plaf.metal.MetalLookAndFeel的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hottub   文件: bug7170310.java
public static void main(String[] args) throws Exception {
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
        SwingUtilities.invokeAndWait(bug7170310::createAndShowUI);

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        toolkit.realSync();

        for (int i = 0; i < TABS_NUMBER; i++) {
            SwingUtilities.invokeAndWait(bug7170310::addTab);
            toolkit.realSync();
        }

        SwingUtilities.invokeAndWait(bug7170310::check);

        if (exception != null) {
            System.out.println("Test failed: " + exception.getMessage());
            throw exception;
        } else {
            System.out.printf("Test passed");
        }
    } finally {
        frame.dispose();
    }
}
 
源代码2 项目: jdk8u-dev-jdk   文件: Test4783068.java
void test() {
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        throw new Error("Cannot set Metal LAF");
    }
    // Render text using background color
    UIManager.put("textInactiveText", TEST_COLOR);

    test(new JLabel(html));
    test(new JButton(html));

    JEditorPane pane = new JEditorPane("text/html", html);
    pane.setDisabledTextColor(TEST_COLOR);
    test(pane);
}
 
源代码3 项目: openjdk-jdk9   文件: bug7170310.java
public static void main(String[] args) throws Exception {
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
        SwingUtilities.invokeAndWait(bug7170310::createAndShowUI);

        sync();

        for (int i = 0; i < TABS_NUMBER; i++) {
            SwingUtilities.invokeAndWait(bug7170310::addTab);
            sync();
        }

        SwingUtilities.invokeAndWait(bug7170310::check);

        if (exception != null) {
            System.out.println("Test failed: " + exception.getMessage());
            throw exception;
        } else {
            System.out.printf("Test passed");
        }
    } finally {
        frame.dispose();
    }
}
 
源代码4 项目: openjdk-8   文件: Metalworks.java
public static void main(String[] args) {
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    JDialog.setDefaultLookAndFeelDecorated(true);
    JFrame.setDefaultLookAndFeelDecorated(true);
    Toolkit.getDefaultToolkit().setDynamicLayout(true);
    System.setProperty("sun.awt.noerasebackground", "true");
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        System.out.println(
                "Metal Look & Feel not supported on this platform. \n"
                + "Program Terminated");
        System.exit(0);
    }
    JFrame frame = new MetalworksFrame();
    frame.setVisible(true);
}
 
源代码5 项目: dragonwell8_jdk   文件: Test8039750.java
public static void main(String[] args) {
    UIDefaults table= new MetalLookAndFeel().getDefaults();
    test(table.get("ToolBar.rolloverBorder"),
            "javax.swing.plaf.metal.MetalBorders$ButtonBorder",
            "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
    test(table.get("ToolBar.nonrolloverBorder"),
            "javax.swing.plaf.metal.MetalBorders$ButtonBorder",
            "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
    test(table.get("RootPane.frameBorder"),
            "javax.swing.plaf.metal.MetalBorders$FrameBorder");
    test(table.get("RootPane.plainDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$DialogBorder");
    test(table.get("RootPane.informationDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$DialogBorder");
    test(table.get("RootPane.errorDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder");
    test(table.get("RootPane.colorChooserDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.fileChooserDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.questionDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.warningDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder");
}
 
源代码6 项目: TencentKona-8   文件: Metalworks.java
public static void main(String[] args) {
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    JDialog.setDefaultLookAndFeelDecorated(true);
    JFrame.setDefaultLookAndFeelDecorated(true);
    Toolkit.getDefaultToolkit().setDynamicLayout(true);
    System.setProperty("sun.awt.noerasebackground", "true");
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        System.out.println(
                "Metal Look & Feel not supported on this platform. \n"
                + "Program Terminated");
        System.exit(0);
    }
    JFrame frame = new MetalworksFrame();
    frame.setVisible(true);
}
 
源代码7 项目: RipplePower   文件: Baseline.java
private static boolean isOceanTheme() {
	if (!inSandbox) {
		try {
			java.lang.reflect.Field field = MetalLookAndFeel.class.getDeclaredField("currentTheme");
			field.setAccessible(true);
			Object theme = field.get(null);
			return "javax.swing.plaf.metal.OceanTheme".equals(theme.getClass().getName());
		} catch (Exception ex) {
			// We're in a sandbox and can't access the field
			inSandbox = true;
		}
	}
	if (!checkedForOcean) {
		checkedForOcean = true;
		checkForOcean();
	}
	return usingOcean;
}
 
源代码8 项目: TencentKona-8   文件: Test4783068.java
void test() {
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        throw new Error("Cannot set Metal LAF");
    }
    // Render text using background color
    UIManager.put("textInactiveText", TEST_COLOR);

    test(new JLabel(html));
    test(new JButton(html));

    JEditorPane pane = new JEditorPane("text/html", html);
    pane.setDisabledTextColor(TEST_COLOR);
    test(pane);
}
 
源代码9 项目: jdk8u-jdk   文件: Test8039750.java
public static void main(String[] args) {
    UIDefaults table= new MetalLookAndFeel().getDefaults();
    test(table.get("ToolBar.rolloverBorder"),
            "javax.swing.plaf.metal.MetalBorders$ButtonBorder",
            "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
    test(table.get("ToolBar.nonrolloverBorder"),
            "javax.swing.plaf.metal.MetalBorders$ButtonBorder",
            "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
    test(table.get("RootPane.frameBorder"),
            "javax.swing.plaf.metal.MetalBorders$FrameBorder");
    test(table.get("RootPane.plainDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$DialogBorder");
    test(table.get("RootPane.informationDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$DialogBorder");
    test(table.get("RootPane.errorDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder");
    test(table.get("RootPane.colorChooserDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.fileChooserDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.questionDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.warningDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder");
}
 
源代码10 项目: jdk8u_jdk   文件: Metalworks.java
public static void main(String[] args) {
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    JDialog.setDefaultLookAndFeelDecorated(true);
    JFrame.setDefaultLookAndFeelDecorated(true);
    Toolkit.getDefaultToolkit().setDynamicLayout(true);
    System.setProperty("sun.awt.noerasebackground", "true");
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        System.out.println(
                "Metal Look & Feel not supported on this platform. \n"
                + "Program Terminated");
        System.exit(0);
    }
    JFrame frame = new MetalworksFrame();
    frame.setVisible(true);
}
 
源代码11 项目: jdk8u60   文件: Metalworks.java
public static void main(String[] args) {
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    JDialog.setDefaultLookAndFeelDecorated(true);
    JFrame.setDefaultLookAndFeelDecorated(true);
    Toolkit.getDefaultToolkit().setDynamicLayout(true);
    System.setProperty("sun.awt.noerasebackground", "true");
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        System.out.println(
                "Metal Look & Feel not supported on this platform. \n"
                + "Program Terminated");
        System.exit(0);
    }
    JFrame frame = new MetalworksFrame();
    frame.setVisible(true);
}
 
源代码12 项目: jdk8u60   文件: bug6342301.java
public static void main(String[] args) throws Exception {
    tempDir = System.getProperty("java.io.tmpdir");

    if (tempDir.length() == 0) { //'java.io.tmpdir' isn't guaranteed to be defined
        tempDir = System.getProperty("user.home");
    }

    System.out.println("Temp directory: " + tempDir);

    UIManager.setLookAndFeel(new MetalLookAndFeel());

    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            HackedFileChooser openChooser = new HackedFileChooser();

            openChooser.setUI(new MetalFileChooserUI(openChooser));
            openChooser.setCurrentDirectory(new File(tempDir));
        }
    });
}
 
源代码13 项目: openjdk-8   文件: Test4783068.java
void test() {
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        throw new Error("Cannot set Metal LAF");
    }
    // Render text using background color
    UIManager.put("textInactiveText", TEST_COLOR);

    test(new JLabel(html));
    test(new JButton(html));

    JEditorPane pane = new JEditorPane("text/html", html);
    pane.setDisabledTextColor(TEST_COLOR);
    test(pane);
}
 
源代码14 项目: openjdk-jdk8u-backup   文件: Test8039750.java
public static void main(String[] args) {
    UIDefaults table= new MetalLookAndFeel().getDefaults();
    test(table.get("ToolBar.rolloverBorder"),
            "javax.swing.plaf.metal.MetalBorders$ButtonBorder",
            "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
    test(table.get("ToolBar.nonrolloverBorder"),
            "javax.swing.plaf.metal.MetalBorders$ButtonBorder",
            "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
    test(table.get("RootPane.frameBorder"),
            "javax.swing.plaf.metal.MetalBorders$FrameBorder");
    test(table.get("RootPane.plainDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$DialogBorder");
    test(table.get("RootPane.informationDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$DialogBorder");
    test(table.get("RootPane.errorDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder");
    test(table.get("RootPane.colorChooserDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.fileChooserDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.questionDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.warningDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder");
}
 
源代码15 项目: weblaf   文件: LookAndFeelInitializationTest.java
/**
 * {@link WebLookAndFeel} installation and uninstallation test through {@link UIManager}.
 */
@Test
public void installUninstallBasic ()
{
    CoreSwingUtils.invokeAndWait ( new Runnable ()
    {
        @Override
        public void run ()
        {
            try
            {
                // Installing WebLookAndFeel
                UIManager.setLookAndFeel ( new WebLookAndFeel () );

                // Uninstalling WebLookAndFeel
                UIManager.setLookAndFeel ( MetalLookAndFeel.class.getCanonicalName () );
            }
            catch ( final Exception e )
            {
                throw new RuntimeException ( e );
            }
        }
    } );
}
 
源代码16 项目: openjdk-jdk9   文件: Metalworks.java
public static void main(String[] args) {
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    JDialog.setDefaultLookAndFeelDecorated(true);
    JFrame.setDefaultLookAndFeelDecorated(true);
    Toolkit.getDefaultToolkit().setDynamicLayout(true);
    System.setProperty("sun.awt.noerasebackground", "true");
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        System.out.println(
                "Metal Look & Feel not supported on this platform. \n"
                + "Program Terminated");
        System.exit(0);
    }
    JFrame frame = new MetalworksFrame();
    frame.setVisible(true);
}
 
源代码17 项目: jdk8u-jdk   文件: Metalworks.java
public static void main(String[] args) {
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    JDialog.setDefaultLookAndFeelDecorated(true);
    JFrame.setDefaultLookAndFeelDecorated(true);
    Toolkit.getDefaultToolkit().setDynamicLayout(true);
    System.setProperty("sun.awt.noerasebackground", "true");
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        System.out.println(
                "Metal Look & Feel not supported on this platform. \n"
                + "Program Terminated");
        System.exit(0);
    }
    JFrame frame = new MetalworksFrame();
    frame.setVisible(true);
}
 
源代码18 项目: openjdk-jdk9   文件: bug6342301.java
public static void main(String[] args) throws Exception {
    tempDir = System.getProperty("java.io.tmpdir");

    if (tempDir.length() == 0) { //'java.io.tmpdir' isn't guaranteed to be defined
        tempDir = System.getProperty("user.home");
    }

    System.out.println("Temp directory: " + tempDir);

    UIManager.setLookAndFeel(new MetalLookAndFeel());

    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            HackedFileChooser openChooser = new HackedFileChooser();

            openChooser.setUI(new MetalFileChooserUI(openChooser));
            openChooser.setCurrentDirectory(new File(tempDir));
        }
    });
}
 
源代码19 项目: netbeans   文件: PlatformInstallIteratorTest.java
public void testSinglePlatformInstall () throws IOException, UnsupportedLookAndFeelException {
    UIManager.setLookAndFeel(new MetalLookAndFeel());
    InstallerRegistry regs = InstallerRegistryAccessor.prepareForUnitTest(new GeneralPlatformInstall[] {
        new FileBasedPlatformInstall ("FileBased1", Collections.<WizardDescriptor.Panel<WizardDescriptor>>singletonList(
            new Panel ("FileBased1_panel1")
        ))
    });
    PlatformInstallIterator iterator = PlatformInstallIterator.create();
    WizardDescriptor wd = new WizardDescriptor (iterator);
    iterator.initialize(wd);
    assertEquals("Invalid state", 1, iterator.getPanelIndex());
    WizardDescriptor.Panel panel = iterator.current();
    assertTrue ("Invalid panel",panel instanceof LocationChooser.Panel);
    ((JFileChooser)panel.getComponent()).setSelectedFile(this.getWorkDir());    //Select some folder
    assertTrue ("LocationChooser is not valid after folder was selected",panel.isValid());
    assertTrue ("Should have next panel",iterator.hasNext());
    assertFalse ("Should not have previous panel", iterator.hasPrevious());
    iterator.nextPanel();
    assertEquals("Invalid state", 2, iterator.getPanelIndex());
    panel = iterator.current();
    assertEquals("Invalid panel","FileBased1_panel1",panel.getComponent().getName());
    assertFalse ("Should not have next panel",iterator.hasNext());
    assertTrue ("Should have previous panel", iterator.hasPrevious());
}
 
源代码20 项目: jdk8u-jdk   文件: Test8039750.java
public static void main(String[] args) {
    UIDefaults table= new MetalLookAndFeel().getDefaults();
    test(table.get("ToolBar.rolloverBorder"),
            "javax.swing.plaf.metal.MetalBorders$ButtonBorder",
            "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
    test(table.get("ToolBar.nonrolloverBorder"),
            "javax.swing.plaf.metal.MetalBorders$ButtonBorder",
            "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
    test(table.get("RootPane.frameBorder"),
            "javax.swing.plaf.metal.MetalBorders$FrameBorder");
    test(table.get("RootPane.plainDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$DialogBorder");
    test(table.get("RootPane.informationDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$DialogBorder");
    test(table.get("RootPane.errorDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder");
    test(table.get("RootPane.colorChooserDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.fileChooserDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.questionDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.warningDialogBorder"),
            "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder");
}
 
源代码21 项目: dragonwell8_jdk   文件: MetalThemeMenu.java
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);
    }

}
 
源代码22 项目: jdk8u-jdk   文件: Test6657026.java
public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new MetalLookAndFeel());

    ThreadGroup group = new ThreadGroup("$$$");
    Thread thread = new Thread(group, new Test6657026());
    thread.start();
    thread.join();

    new JInternalFrame().setContentPane(new JPanel());
}
 
源代码23 项目: jdk8u-dev-jdk   文件: bug6559589.java
public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new MetalLookAndFeel());
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            bug6559589.createGui();
        }
    });
}
 
源代码24 项目: jdk8u-dev-jdk   文件: bug6742358.java
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);
}
 
源代码25 项目: jdk8u-jdk   文件: bug8048506.java
public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new MetalLookAndFeel());

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            createAndShowGUI();
        }
    });
    System.out.println("The test passed");
}
 
源代码26 项目: dragonwell8_jdk   文件: bug7068740.java
public static void main(String[] args) throws Exception {
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
        setUp();
        doTest();
    } catch (UnsupportedLookAndFeelException e) {
        e.printStackTrace();
        throw new RuntimeException("Test failed");
    }
}
 
源代码27 项目: jdk8u_jdk   文件: bug6559589.java
public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new MetalLookAndFeel());
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            bug6559589.createGui();
        }
    });
}
 
源代码28 项目: openjdk-8   文件: bug7068740.java
public static void main(String[] args) throws Exception {
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
        setUp();
        doTest();
    } catch (UnsupportedLookAndFeelException e) {
        e.printStackTrace();
        throw new RuntimeException("Test failed");
    }
}
 
源代码29 项目: jdk8u-jdk   文件: MouseComboBoxTest.java
public static void main(String[] args) throws Exception {
    toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    robot = new Robot();
    robot.setAutoDelay(50);

    UIManager.setLookAndFeel(new MetalLookAndFeel());
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            createAndShowGUI();
        }
    });
    toolkit.realSync();

    for (int i = 0; i < items.length; i++) {
        // Open popup
        robot.keyPress(KeyEvent.VK_DOWN);
        robot.keyRelease(KeyEvent.VK_DOWN);
        toolkit.realSync();

        Point point = getItemPointToClick(i);
        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        toolkit.realSync();

        if (i != getSelectedIndex()) {
            throw new RuntimeException("Test Failed! Incorrect value of selected index = " + getSelectedIndex() +
                    ", expected value = " + i);
        }
    }
}
 
源代码30 项目: openjdk-8   文件: bug6742358.java
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);
}
 
 类所在包
 类方法
 同包方法