1
1
/*
2
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2013, 2020, 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
22
22
*/
23
23
24
24
import java .awt .BorderLayout ;
25
-
26
25
import java .awt .Container ;
27
26
import java .awt .Rectangle ;
28
- import java .awt .Toolkit ;
27
+ import java .awt .Robot ;
29
28
30
29
import javax .swing .JButton ;
31
30
import javax .swing .JCheckBox ;
32
- import javax .swing .JTabbedPane ;
33
-
34
31
import javax .swing .JFrame ;
32
+ import javax .swing .JTabbedPane ;
35
33
import javax .swing .SwingUtilities ;
36
34
import javax .swing .UIManager ;
37
35
import javax .swing .UIManager .LookAndFeelInfo ;
41
39
* @key headful
42
40
* @bug 7024235
43
41
* @summary Tests JFrame.pack() with the JTabbedPane
44
- * @library /lib/client/
45
- * @build ExtendedRobot
46
- * @author Sergey Malenkov
47
42
* @run main Test7024235
48
43
*/
49
44
@@ -54,12 +49,15 @@ public class Test7024235 implements Runnable {
54
49
public static void main (String [] args ) throws Exception {
55
50
Test7024235 test = new Test7024235 ();
56
51
for (LookAndFeelInfo info : UIManager .getInstalledLookAndFeels ()) {
57
- UIManager .setLookAndFeel (info .getClassName ());
52
+ String className = info .getClassName ();
53
+ System .out .println ("className = " + className );
54
+ UIManager .setLookAndFeel (className );
58
55
59
56
test .test ();
60
57
try {
61
- ExtendedRobot robot = new ExtendedRobot ();
62
- robot .waitForIdle (1000 );
58
+ Robot robot = new Robot ();
59
+ robot .waitForIdle ();
60
+ robot .delay (1000 );
63
61
}catch (Exception ex ) {
64
62
ex .printStackTrace ();
65
63
throw new Error ("Unexpected Failure" );
@@ -81,6 +79,7 @@ public void run() {
81
79
JFrame frame = new JFrame ();
82
80
frame .add (BorderLayout .WEST , this .pane );
83
81
frame .pack ();
82
+ frame .setLocationRelativeTo (null );
84
83
frame .setVisible (true );
85
84
86
85
test ("first" );
@@ -105,6 +104,9 @@ private void test(String step) {
105
104
this .passed = true ;
106
105
for (int index = 0 ; index < this .pane .getTabCount (); index ++) {
107
106
Rectangle bounds = this .pane .getBoundsAt (index );
107
+ if (bounds == null ) {
108
+ continue ;
109
+ }
108
110
int centerX = bounds .x + bounds .width / 2 ;
109
111
int centerY = bounds .y + bounds .height / 2 ;
110
112
int actual = this .pane .indexAtLocation (centerX , centerY );
0 commit comments