|
1 | 1 | /* |
2 | | - * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
21 | 21 | * questions. |
22 | 22 | */ |
23 | 23 |
|
24 | | -/* @test |
| 24 | +/* |
| 25 | + * @test |
25 | 26 | * @key headful |
26 | 27 | * @bug 6725409 |
27 | 28 | * @requires (os.family == "windows") |
28 | 29 | * @summary Checks that JInternalFrame's system menu |
29 | 30 | * can be localized during run-time |
30 | | - * @author Mikhail Lapshin |
31 | | - * @library /lib/client/ |
32 | 31 | * @modules java.desktop/com.sun.java.swing.plaf.windows |
33 | | - * @build ExtendedRobot |
34 | 32 | * @run main bug6725409 |
35 | 33 | */ |
36 | 34 |
|
37 | | -import javax.swing.*; |
38 | | -import java.awt.*; |
| 35 | +import java.awt.Robot; |
| 36 | +import javax.swing.JDesktopPane; |
| 37 | +import javax.swing.JFrame; |
| 38 | +import javax.swing.JInternalFrame; |
| 39 | +import javax.swing.JMenuItem; |
| 40 | +import javax.swing.JPopupMenu; |
| 41 | +import javax.swing.SwingUtilities; |
| 42 | +import javax.swing.UIManager; |
| 43 | + |
| 44 | +import com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel; |
| 45 | +import com.sun.java.swing.plaf.windows.WindowsInternalFrameTitlePane; |
39 | 46 |
|
40 | 47 | public class bug6725409 { |
41 | 48 | private JFrame frame; |
42 | 49 | private JInternalFrame iFrame; |
43 | | - private TestTitlePane testTitlePane; |
44 | | - private boolean passed; |
45 | | - private static ExtendedRobot robot = createRobot(); |
| 50 | + private static TestTitlePane testTitlePane; |
| 51 | + private static volatile boolean passed; |
| 52 | + private static Robot robot; |
46 | 53 |
|
47 | 54 | public static void main(String[] args) throws Exception { |
48 | | - try { |
49 | | - UIManager.setLookAndFeel( |
50 | | - new com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel()); |
51 | | - } catch(UnsupportedLookAndFeelException e) { |
52 | | - System.out.println("The test is for Windows LaF only"); |
53 | | - return; |
54 | | - } |
| 55 | + UIManager.setLookAndFeel( |
| 56 | + new WindowsClassicLookAndFeel()); |
55 | 57 |
|
| 58 | + robot = new Robot(); |
56 | 59 | final bug6725409 bug6725409 = new bug6725409(); |
57 | 60 | try { |
58 | | - SwingUtilities.invokeAndWait(new Runnable() { |
59 | | - public void run() { |
60 | | - bug6725409.setupUIStep1(); |
61 | | - } |
62 | | - }); |
| 61 | + SwingUtilities.invokeAndWait(bug6725409::setupUIStep1); |
63 | 62 | sync(); |
64 | | - SwingUtilities.invokeAndWait(new Runnable() { |
65 | | - public void run() { |
66 | | - bug6725409.setupUIStep2(); |
67 | | - } |
68 | | - }); |
| 63 | + SwingUtilities.invokeAndWait(bug6725409::setupUIStep2); |
69 | 64 | sync(); |
70 | | - SwingUtilities.invokeAndWait(new Runnable() { |
71 | | - public void run() { |
72 | | - bug6725409.test(); |
73 | | - } |
74 | | - }); |
| 65 | + SwingUtilities.invokeAndWait(bug6725409::test); |
75 | 66 | sync(); |
76 | 67 | bug6725409.checkResult(); |
77 | 68 | } finally { |
78 | | - if (bug6725409.frame != null) { |
79 | | - bug6725409.frame.dispose(); |
80 | | - } |
| 69 | + SwingUtilities.invokeAndWait(() -> { |
| 70 | + if (bug6725409.frame != null) { |
| 71 | + bug6725409.frame.dispose(); |
| 72 | + } |
| 73 | + }); |
81 | 74 | } |
82 | 75 | } |
83 | 76 |
|
84 | 77 | private void setupUIStep1() { |
85 | | - frame = new JFrame(); |
| 78 | + frame = new JFrame("bug6725409"); |
86 | 79 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
87 | 80 |
|
88 | 81 | JDesktopPane desktop = new JDesktopPane(); |
@@ -147,19 +140,9 @@ private void checkResult() { |
147 | 140 | private static void sync() { |
148 | 141 | robot.waitForIdle(); |
149 | 142 | } |
150 | | - private static ExtendedRobot createRobot() { |
151 | | - try { |
152 | | - ExtendedRobot robot = new ExtendedRobot(); |
153 | | - return robot; |
154 | | - }catch(Exception ex) { |
155 | | - ex.printStackTrace(); |
156 | | - throw new Error("Unexpected Failure"); |
157 | | - } |
158 | | - } |
159 | 143 |
|
160 | 144 | // Extend WindowsInternalFrameTitlePane to get access to systemPopupMenu |
161 | | - private class TestTitlePane extends |
162 | | - com.sun.java.swing.plaf.windows.WindowsInternalFrameTitlePane { |
| 145 | + private class TestTitlePane extends WindowsInternalFrameTitlePane { |
163 | 146 | private JPopupMenu systemPopupMenu; |
164 | 147 |
|
165 | 148 | public TestTitlePane(JInternalFrame f) { |
|
0 commit comments