Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Mouse/MouseWheelAbsXY/MouseWheelAbsXY.java
41152 views
1
/*
2
* Copyright (c) 2015, 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.AWTException;
25
import java.awt.Frame;
26
import java.awt.GraphicsConfiguration;
27
import java.awt.GraphicsDevice;
28
import java.awt.GraphicsEnvironment;
29
import java.awt.Robot;
30
import java.awt.Window;
31
import java.awt.event.InputEvent;
32
33
import static java.awt.GraphicsEnvironment.*;
34
35
/**
36
* @test
37
* @key headful
38
* @bug 6778087
39
*/
40
public final class MouseWheelAbsXY {
41
42
private static boolean done;
43
private static int wheelX;
44
private static int wheelY;
45
private static int mouseX;
46
private static int mouseY;
47
48
public static void main(final String[] args) throws AWTException {
49
GraphicsEnvironment ge = getLocalGraphicsEnvironment();
50
GraphicsDevice[] sds = ge.getScreenDevices();
51
for (GraphicsDevice gd : sds) {
52
test(gd.getDefaultConfiguration());
53
}
54
}
55
56
private static void test(GraphicsConfiguration gc) throws AWTException {
57
final Window frame = new Frame(gc);
58
try {
59
frame.addMouseWheelListener(e -> {
60
wheelX = e.getXOnScreen();
61
wheelY = e.getYOnScreen();
62
done = true;
63
});
64
frame.setSize(300, 300);
65
frame.setVisible(true);
66
67
final Robot robot = new Robot();
68
robot.setAutoDelay(50);
69
robot.setAutoWaitForIdle(true);
70
mouseX = frame.getX() + frame.getWidth() / 2;
71
mouseY = frame.getY() + frame.getHeight() / 2;
72
73
robot.mouseMove(mouseX, mouseY);
74
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
75
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
76
robot.mouseWheel(10);
77
78
validate();
79
} finally {
80
frame.dispose();
81
}
82
}
83
84
private static void validate() {
85
if (!done || wheelX != mouseX || wheelY != mouseY) {
86
System.err.println("Expected X: " + mouseX);
87
System.err.println("Expected Y: " + mouseY);
88
System.err.println("Actual X: " + wheelX);
89
System.err.println("Actual Y: " + wheelY);
90
throw new RuntimeException("Test failed");
91
}
92
}
93
}
94
95