44
44
45
45
public class JPanelCursorTest {
46
46
public static void main (String [] args ) throws Exception {
47
- String INSTRUCTIONS = """
47
+ final String INSTRUCTIONS = """
48
48
This test checks for setCursor in a JPanel when added to a
49
49
JFrame's contentPane.
50
50
51
51
1. Verify that the cursor in the left side of the test window
52
- is a default cursor.
52
+ is a text cursor.
53
53
2. Verify that the cursor changes to the crosshair cursor when
54
54
pointing over the button.
55
55
3. Verify that the cursor changes to the hand cursor when in
56
56
the right side of the splitpane (and not on the button).
57
+ 4. Verify that the cursor changes to the wait cursor when in
58
+ the empty bottom section of the test window.
57
59
58
60
If true, then pass the test. Otherwise, fail this test.
59
61
""" ;
60
62
61
63
PassFailJFrame .builder ()
62
64
.title ("Test Instructions" )
63
65
.instructions (INSTRUCTIONS )
64
- .columns (35 )
66
+ .columns (37 )
65
67
.testUI (JPanelCursorTest ::createUI )
66
68
.build ()
67
69
.awaitAndCheck ();
68
70
}
69
71
70
72
public static JFrame createUI () {
71
- JFrame frame = new JFrame ();
73
+ JFrame frame = new JFrame ("Cursor Test Frame" );
72
74
73
75
JSplitPane j = new JSplitPane (JSplitPane .HORIZONTAL_SPLIT );
74
76
ExtJComponent pane = new ExtJComponent ();
@@ -78,11 +80,12 @@ public static JFrame createUI() {
78
80
j .setLeftComponent (pane );
79
81
j .setRightComponent (panel );
80
82
j .setContinuousLayout (true );
83
+ j .setSize (200 , 200 );
81
84
82
- frame .getContentPane ().add ("Center " , j );
83
- pane .setCursor (Cursor .getPredefinedCursor (Cursor .MOVE_CURSOR ));
85
+ frame .getContentPane ().add ("North " , j );
86
+ pane .setCursor (Cursor .getPredefinedCursor (Cursor .TEXT_CURSOR ));
84
87
frame .setCursor (Cursor .getPredefinedCursor (Cursor .WAIT_CURSOR ));
85
- frame .pack ( );
88
+ frame .setSize ( 300 , 200 );
86
89
return frame ;
87
90
}
88
91
}
@@ -96,15 +99,15 @@ public ExtJComponent() {
96
99
setBorder (new BevelBorder (BevelBorder .RAISED ));
97
100
}
98
101
public void paintComponent (Graphics g ) {
99
- g .drawString ("Default " , 20 , 30 );
102
+ g .drawString ("Text " , 20 , 30 );
100
103
}
101
104
public Dimension getPreferredSize () {
102
105
return new Dimension (100 , 100 );
103
106
}
104
107
}
105
108
106
109
class CursorBugPanel extends JPanel {
107
- public CursorBugPanel () {
110
+ public CursorBugPanel () {
108
111
// BUG: fails to set cursor for panel
109
112
setCursor (Cursor .getPredefinedCursor (Cursor .HAND_CURSOR ));
110
113
0 commit comments