1
1
/*
2
- * Copyright (c) 2004, 2023 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2004, 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
30
30
import javax .swing .JTextField ;
31
31
import javax .swing .JToolBar ;
32
32
import javax .swing .SwingUtilities ;
33
+ import javax .swing .plaf .basic .BasicToolBarUI ;
33
34
34
35
/*
35
36
* @test
@@ -45,7 +46,7 @@ public class bug4529206 {
45
46
static JButton jButton1 ;
46
47
47
48
private static void test () {
48
- frame = new JFrame ();
49
+ frame = new JFrame ("bug4529206" );
49
50
JPanel jPanFrame = (JPanel ) frame .getContentPane ();
50
51
jPanFrame .setLayout (new BorderLayout ());
51
52
frame .setSize (new Dimension (200 , 100 ));
@@ -64,7 +65,7 @@ private static void test() {
64
65
}
65
66
66
67
private static void makeToolbarFloat () {
67
- javax . swing . plaf . basic . BasicToolBarUI ui = (javax . swing . plaf . basic . BasicToolBarUI ) jToolBar1 .getUI ();
68
+ BasicToolBarUI ui = (BasicToolBarUI ) jToolBar1 .getUI ();
68
69
if (!ui .isFloating ()) {
69
70
ui .setFloatingLocation (100 , 100 );
70
71
ui .setFloating (true , jToolBar1 .getLocation ());
@@ -79,16 +80,17 @@ public static void main(String[] args) throws Exception {
79
80
try {
80
81
SwingUtilities .invokeAndWait (() -> test ());
81
82
Robot robot = new Robot ();
82
- robot .setAutoWaitForIdle ( true );
83
+ robot .waitForIdle ( );
83
84
robot .delay (1000 );
84
85
85
86
SwingUtilities .invokeAndWait (() -> makeToolbarFloat ());
87
+ robot .waitForIdle ();
86
88
robot .delay (300 );
87
89
88
90
SwingUtilities .invokeAndWait (() -> {
89
91
if (frame .isFocused ()) {
90
- throw
91
- new RuntimeException ( "setFloating does not work correctly" );
92
+ throw new RuntimeException (
93
+ "setFloating does not work correctly" );
92
94
}
93
95
});
94
96
} finally {
0 commit comments