Skip to content

Commit 808bb1f

Browse files
author
Harshitha Onkar
committedAug 17, 2023
8314246: javax/swing/JToolBar/4529206/bug4529206.java fails intermittently on Linux
Reviewed-by: dnguyen, serb
1 parent 6445314 commit 808bb1f

File tree

1 file changed

+19
-33
lines changed

1 file changed

+19
-33
lines changed
 

‎test/jdk/javax/swing/JToolBar/4529206/bug4529206.java

+19-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2023, 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,26 +21,24 @@
2121
* questions.
2222
*/
2323

24-
/*
25-
* @test
26-
* @key headful
27-
* @bug 4529206
28-
* @summary JToolBar - setFloating does not work correctly
29-
* @run main bug4529206
30-
*/
31-
3224
import java.awt.BorderLayout;
3325
import java.awt.Dimension;
3426
import java.awt.Robot;
35-
import java.awt.event.ActionEvent;
36-
import java.awt.event.ActionListener;
3727
import javax.swing.JButton;
3828
import javax.swing.JFrame;
3929
import javax.swing.JPanel;
4030
import javax.swing.JTextField;
4131
import javax.swing.JToolBar;
4232
import javax.swing.SwingUtilities;
4333

34+
/*
35+
* @test
36+
* @key headful
37+
* @bug 4529206
38+
* @summary JToolBar - setFloating does not work correctly
39+
* @run main bug4529206
40+
*/
41+
4442
public class bug4529206 {
4543
static JFrame frame;
4644
static JToolBar jToolBar1;
@@ -58,11 +56,7 @@ private static void test() {
5856
JTextField tf = new JTextField("click here");
5957
jPanFrame.add(tf);
6058
jToolBar1.add(jButton1, null);
61-
jButton1.addActionListener(new ActionListener() {
62-
public void actionPerformed(ActionEvent e) {
63-
buttonPressed(e);
64-
}
65-
});
59+
jButton1.addActionListener(e -> buttonPressed());
6660

6761
frame.setUndecorated(true);
6862
frame.setLocationRelativeTo(null);
@@ -77,32 +71,24 @@ private static void makeToolbarFloat() {
7771
}
7872
}
7973

80-
private static void buttonPressed(ActionEvent e) {
74+
private static void buttonPressed() {
8175
makeToolbarFloat();
8276
}
8377

8478
public static void main(String[] args) throws Exception {
8579
try {
86-
SwingUtilities.invokeAndWait(new Runnable() {
87-
public void run() {
88-
test();
89-
}
90-
});
80+
SwingUtilities.invokeAndWait(() -> test());
9181
Robot robot = new Robot();
92-
robot.waitForIdle();
82+
robot.setAutoWaitForIdle(true);
9383
robot.delay(1000);
9484

95-
SwingUtilities.invokeAndWait(() -> {
96-
makeToolbarFloat();
97-
});
85+
SwingUtilities.invokeAndWait(() -> makeToolbarFloat());
86+
robot.delay(300);
9887

99-
robot.waitForIdle();
100-
SwingUtilities.invokeAndWait(new Runnable() {
101-
public void run() {
102-
if (frame.isFocused()) {
103-
throw
104-
new RuntimeException("setFloating does not work correctly");
105-
}
88+
SwingUtilities.invokeAndWait(() -> {
89+
if (frame.isFocused()) {
90+
throw
91+
new RuntimeException("setFloating does not work correctly");
10692
}
10793
});
10894
} finally {

0 commit comments

Comments
 (0)
Please sign in to comment.