Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Mixing/AWT_Mixing/FrameBorderCounter.java
47626 views
1
/*
2
* Copyright (c) 2014, 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
import java.awt.Dimension;
24
import java.awt.EventQueue;
25
import java.awt.Frame;
26
import java.awt.Point;
27
import java.awt.Robot;
28
import java.awt.event.MouseEvent;
29
import java.awt.event.MouseAdapter;
30
import java.awt.event.WindowEvent;
31
import java.awt.event.WindowAdapter;
32
33
public class FrameBorderCounter {
34
35
private static Frame frame;
36
private static Frame background;
37
private static Dimension size;
38
private static Point location;
39
private static Point entered;
40
41
public static void main(String[] args) throws Exception {
42
final Robot robot = new Robot();
43
EventQueue.invokeAndWait(new Runnable() {
44
public void run() {
45
robot.mouseMove(0, 0);
46
}
47
});
48
EventQueue.invokeAndWait(new Runnable() {
49
public void run() {
50
background = new Frame();
51
background.setBounds(100, 100, 300, 300);
52
background.addMouseListener(new MouseAdapter() {
53
@Override
54
public void mouseEntered(MouseEvent e) {
55
entered = e.getLocationOnScreen();
56
System.err.println("[ENTERED] : " + entered);
57
}
58
});
59
background.setVisible(true);
60
}
61
});
62
EventQueue.invokeAndWait(new Runnable() {
63
public void run() {
64
frame = new Frame("Frame");
65
frame.setBounds(200, 200, 100, 100);
66
frame.setVisible(true);
67
}
68
});
69
Thread.sleep(1000);
70
EventQueue.invokeAndWait(new Runnable() {
71
public void run() {
72
location = frame.getLocationOnScreen();
73
size = frame.getSize();
74
}
75
});
76
int out = 20;
77
for (int x = location.x + size.width - out; x <= location.x + size.width + out; ++x) {
78
robot.mouseMove(x, location.y + size.height / 2);
79
Thread.sleep(50);
80
}
81
System.err.println("[LOCATION] : " + location);
82
System.err.println("[SIZE] : " + size);
83
Thread.sleep(250);
84
int shift = entered.x - location.x - size.width - 1;
85
System.err.println("Done");
86
System.out.println(shift);
87
frame.dispose();
88
background.dispose();
89
}
90
}
91
92