Skip to content

Commit 34fd121

Browse files
committed
8339524: Clean up a few ExtendedRobot tests
Backport-of: 16232578d9acf9d0b5a9ad0e7530291471b5cc9c
1 parent 255a4aa commit 34fd121

File tree

1 file changed

+30
-47
lines changed

1 file changed

+30
-47
lines changed

test/jdk/javax/swing/JInternalFrame/6725409/bug6725409.java

Lines changed: 30 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
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.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,68 +21,61 @@
2121
* questions.
2222
*/
2323

24-
/* @test
24+
/*
25+
* @test
2526
* @key headful
2627
* @bug 6725409
2728
* @requires (os.family == "windows")
2829
* @summary Checks that JInternalFrame's system menu
2930
* can be localized during run-time
30-
* @author Mikhail Lapshin
31-
* @library /lib/client/
3231
* @modules java.desktop/com.sun.java.swing.plaf.windows
33-
* @build ExtendedRobot
3432
* @run main bug6725409
3533
*/
3634

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;
3946

4047
public class bug6725409 {
4148
private JFrame frame;
4249
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;
4653

4754
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());
5557

58+
robot = new Robot();
5659
final bug6725409 bug6725409 = new bug6725409();
5760
try {
58-
SwingUtilities.invokeAndWait(new Runnable() {
59-
public void run() {
60-
bug6725409.setupUIStep1();
61-
}
62-
});
61+
SwingUtilities.invokeAndWait(bug6725409::setupUIStep1);
6362
sync();
64-
SwingUtilities.invokeAndWait(new Runnable() {
65-
public void run() {
66-
bug6725409.setupUIStep2();
67-
}
68-
});
63+
SwingUtilities.invokeAndWait(bug6725409::setupUIStep2);
6964
sync();
70-
SwingUtilities.invokeAndWait(new Runnable() {
71-
public void run() {
72-
bug6725409.test();
73-
}
74-
});
65+
SwingUtilities.invokeAndWait(bug6725409::test);
7566
sync();
7667
bug6725409.checkResult();
7768
} 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+
});
8174
}
8275
}
8376

8477
private void setupUIStep1() {
85-
frame = new JFrame();
78+
frame = new JFrame("bug6725409");
8679
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
8780

8881
JDesktopPane desktop = new JDesktopPane();
@@ -147,19 +140,9 @@ private void checkResult() {
147140
private static void sync() {
148141
robot.waitForIdle();
149142
}
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-
}
159143

160144
// 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 {
163146
private JPopupMenu systemPopupMenu;
164147

165148
public TestTitlePane(JInternalFrame f) {

0 commit comments

Comments
 (0)