8314246: javax/swing/JToolBar/4529206/bug4529206.java fails intermittently on Linux

Reviewed-by: dnguyen, serb
This commit is contained in:
Harshitha Onkar 2023-08-17 20:37:06 +00:00
parent 6445314fec
commit 808bb1f7bc

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,19 +21,9 @@
* questions.
*/
/*
* @test
* @key headful
* @bug 4529206
* @summary JToolBar - setFloating does not work correctly
* @run main bug4529206
*/
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
@ -41,6 +31,14 @@ import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
/*
* @test
* @key headful
* @bug 4529206
* @summary JToolBar - setFloating does not work correctly
* @run main bug4529206
*/
public class bug4529206 {
static JFrame frame;
static JToolBar jToolBar1;
@ -58,11 +56,7 @@ public class bug4529206 {
JTextField tf = new JTextField("click here");
jPanFrame.add(tf);
jToolBar1.add(jButton1, null);
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
buttonPressed(e);
}
});
jButton1.addActionListener(e -> buttonPressed());
frame.setUndecorated(true);
frame.setLocationRelativeTo(null);
@ -77,32 +71,24 @@ public class bug4529206 {
}
}
private static void buttonPressed(ActionEvent e) {
private static void buttonPressed() {
makeToolbarFloat();
}
public static void main(String[] args) throws Exception {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
test();
}
});
SwingUtilities.invokeAndWait(() -> test());
Robot robot = new Robot();
robot.waitForIdle();
robot.setAutoWaitForIdle(true);
robot.delay(1000);
SwingUtilities.invokeAndWait(() -> {
makeToolbarFloat();
});
SwingUtilities.invokeAndWait(() -> makeToolbarFloat());
robot.delay(300);
robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
if (frame.isFocused()) {
throw
new RuntimeException("setFloating does not work correctly");
}
SwingUtilities.invokeAndWait(() -> {
if (frame.isFocused()) {
throw
new RuntimeException("setFloating does not work correctly");
}
});
} finally {