javax.swing.plaf.metal.MetalLookAndFeel Java Examples

The following examples show how to use javax.swing.plaf.metal.MetalLookAndFeel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: bug6342301.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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));
        }
    });
}
 
Example #2
Source File: Test8039750.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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");
}
 
Example #3
Source File: Test4783068.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: Metalworks.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: PlatformInstallIteratorTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example #6
Source File: bug7170310.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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();
    }
}
 
Example #7
Source File: Test8039750.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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");
}
 
Example #8
Source File: bug6342301.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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));
        }
    });
}
 
Example #9
Source File: Metalworks.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #10
Source File: Baseline.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #11
Source File: Test4783068.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #12
Source File: bug7170310.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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();
    }
}
 
Example #13
Source File: Metalworks.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #14
Source File: Test4783068.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #15
Source File: Test8039750.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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");
}
 
Example #16
Source File: Metalworks.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #17
Source File: Test8039750.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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");
}
 
Example #18
Source File: LookAndFeelInitializationTest.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
/**
 * {@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 );
            }
        }
    } );
}
 
Example #19
Source File: Metalworks.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #20
Source File: bug7068740.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
    }
}
 
Example #21
Source File: MetalLayoutStyle.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
public MetalLayoutStyle() {
	isOcean = false;
	try {
		Method method = MetalLookAndFeel.class.getMethod("getCurrentTheme", (Class[]) null);
		isOcean = ((MetalTheme) method.invoke(null, (Object[]) null)).getName() == "Ocean";
	} catch (NoSuchMethodException nsme) {
	} catch (IllegalAccessException iae) {
	} catch (IllegalArgumentException iae2) {
	} catch (InvocationTargetException ite) {
	}
}
 
Example #22
Source File: bug6742358.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #23
Source File: bug6742358.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #24
Source File: MouseComboBoxTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #25
Source File: Test6657026.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example #26
Source File: bug8132119.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void setMetalLAF() {
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #27
Source File: FPMethodCalledTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI(Test test) {

        try {
            UIManager.setLookAndFeel(new MetalLookAndFeel());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        frame = new JFrame();
        frame.setSize(300, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel panel = new JPanel(new FlowLayout());

        String text = "AAAAAAA";
        textField = test.isPasswordField()
                ? new JPasswordField(text)
                : new JTextField(text);

        textField.setUI(new MetalTextFieldUI() {

            @Override
            public View create(Element elem) {
                return test.createView(elem);
            }
        });

        panel.add(textField);
        frame.getContentPane().add(panel);
        frame.setVisible(true);
    }
 
Example #28
Source File: bug6559589.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new MetalLookAndFeel());
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            bug6559589.createGui();
        }
    });
}
 
Example #29
Source File: bug8032878.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new MetalLookAndFeel());

    final bug8032878 test = new bug8032878();

    test.test(false);
    test.test(true);
}
 
Example #30
Source File: MouseComboBoxTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    robot = new Robot();
    robot.setAutoDelay(50);

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

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

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

        if (i != getSelectedIndex()) {
            throw new RuntimeException("Test Failed! Incorrect value of selected index = " + getSelectedIndex() +
                    ", expected value = " + i);
        }
    }
}