Skip to content

Commit c631719

Browse files
author
Damon Nguyen
committed
8343170: java/awt/Cursor/JPanelCursorTest/JPanelCursorTest.java does not show the default cursor
Reviewed-by: honkar, azvegint, achung
1 parent 29d648c commit c631719

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

test/jdk/java/awt/Cursor/JPanelCursorTest/JPanelCursorTest.java

+12-9
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,33 @@
4444

4545
public class JPanelCursorTest {
4646
public static void main(String[] args) throws Exception {
47-
String INSTRUCTIONS = """
47+
final String INSTRUCTIONS = """
4848
This test checks for setCursor in a JPanel when added to a
4949
JFrame's contentPane.
5050
5151
1. Verify that the cursor in the left side of the test window
52-
is a default cursor.
52+
is a text cursor.
5353
2. Verify that the cursor changes to the crosshair cursor when
5454
pointing over the button.
5555
3. Verify that the cursor changes to the hand cursor when in
5656
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.
5759
5860
If true, then pass the test. Otherwise, fail this test.
5961
""";
6062

6163
PassFailJFrame.builder()
6264
.title("Test Instructions")
6365
.instructions(INSTRUCTIONS)
64-
.columns(35)
66+
.columns(37)
6567
.testUI(JPanelCursorTest::createUI)
6668
.build()
6769
.awaitAndCheck();
6870
}
6971

7072
public static JFrame createUI() {
71-
JFrame frame = new JFrame();
73+
JFrame frame = new JFrame("Cursor Test Frame");
7274

7375
JSplitPane j = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
7476
ExtJComponent pane = new ExtJComponent();
@@ -78,11 +80,12 @@ public static JFrame createUI() {
7880
j.setLeftComponent(pane);
7981
j.setRightComponent(panel);
8082
j.setContinuousLayout(true);
83+
j.setSize(200, 200);
8184

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));
8487
frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
85-
frame.pack();
88+
frame.setSize(300, 200);
8689
return frame;
8790
}
8891
}
@@ -96,15 +99,15 @@ public ExtJComponent() {
9699
setBorder(new BevelBorder(BevelBorder.RAISED));
97100
}
98101
public void paintComponent(Graphics g) {
99-
g.drawString("Default", 20, 30);
102+
g.drawString("Text", 20, 30);
100103
}
101104
public Dimension getPreferredSize() {
102105
return new Dimension(100, 100);
103106
}
104107
}
105108

106109
class CursorBugPanel extends JPanel {
107-
public CursorBugPanel () {
110+
public CursorBugPanel() {
108111
// BUG: fails to set cursor for panel
109112
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
110113

0 commit comments

Comments
 (0)