Skip to content

Commit a81169a

Browse files
committed
8328279: Convert java/awt/Cursor/CursorOverlappedPanelsTest test to main
Backport-of: 2094ff3c7ad829355bf13760d9a19b37649b3517
1 parent 73ece76 commit a81169a

File tree

3 files changed

+90
-258
lines changed

3 files changed

+90
-258
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
import java.awt.Cursor;
25+
import java.awt.Dimension;
26+
import java.awt.Frame;
27+
import java.awt.Point;
28+
import java.lang.reflect.InvocationTargetException;
29+
import javax.swing.BorderFactory;
30+
import javax.swing.JFrame;
31+
import javax.swing.JLayeredPane;
32+
import javax.swing.JPanel;
33+
34+
/*
35+
* @test
36+
* @bug 8007155
37+
* @summary [macosx] Disabled panel takes mouse input in JLayeredPane
38+
* @library /java/awt/regtesthelpers
39+
* @build PassFailJFrame
40+
* @run main/manual CursorOverlappedPanelsTest
41+
*/
42+
43+
public class CursorOverlappedPanelsTest extends Frame {
44+
public static JFrame initialize() {
45+
final JFrame frame = new JFrame("Overlapping Panels Cursor Test");
46+
47+
JLayeredPane layeredPane = new JLayeredPane();
48+
layeredPane.setPreferredSize(new Dimension(400, 400));
49+
JPanel enabledPanel = createPanel(new Point(10, 10), true);
50+
JPanel disabledPanel = createPanel(new Point(100, 100), false);
51+
layeredPane.add(disabledPanel, JLayeredPane.PALETTE_LAYER);
52+
layeredPane.add(enabledPanel, JLayeredPane.DEFAULT_LAYER);
53+
54+
frame.getContentPane().add(layeredPane);
55+
frame.pack();
56+
return frame;
57+
}
58+
59+
private static JPanel createPanel(Point location, boolean enabled) {
60+
final JPanel panel = new JPanel();
61+
panel.setOpaque(false);
62+
panel.setEnabled(enabled);
63+
panel.setSize(new Dimension(200, 200));
64+
panel.setLocation(location);
65+
panel.setBorder(BorderFactory.createTitledBorder(
66+
enabled ? "Enabled" : "Disabled"));
67+
panel.setCursor(Cursor.getPredefinedCursor(
68+
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
69+
return panel;
70+
}
71+
72+
public static void main(String[] args) throws InterruptedException,
73+
InvocationTargetException {
74+
String instructions = """
75+
1) Move the mouse cursor into the area
76+
of Enabled and Disabled panels intersection;
77+
2) Check that the crosshair cursor is displayed.
78+
If so, press PASS, otherwise press FAIL.
79+
""";
80+
81+
PassFailJFrame.builder()
82+
.title("Overlapping Panels Cursor Test Instructions")
83+
.instructions(instructions)
84+
.rows((int) instructions.lines().count() + 1)
85+
.columns(30)
86+
.testUI(CursorOverlappedPanelsTest::initialize)
87+
.build()
88+
.awaitAndCheck();
89+
}
90+
}

test/jdk/java/awt/Cursor/CursorOverlappedPanelsTest/CursorOverlappedPanelsTest.html

Lines changed: 0 additions & 32 deletions
This file was deleted.

test/jdk/java/awt/Cursor/CursorOverlappedPanelsTest/CursorOverlappedPanelsTest.java

Lines changed: 0 additions & 226 deletions
This file was deleted.

0 commit comments

Comments
 (0)