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,6 +21,16 @@
* questions.
*/
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Robot;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
/*
* @test
* @key headful
@ -29,18 +39,6 @@
* @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;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
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,33 +71,25 @@ 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() {
SwingUtilities.invokeAndWait(() -> {
if (frame.isFocused()) {
throw
new RuntimeException("setFloating does not work correctly");
}
}
});
} finally {
SwingUtilities.invokeAndWait(() -> {