Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Mixing/AWT_Mixing/FrameBorderCounter.java
41152 views
1
/*
2
* Copyright (c) 2014, 2018, 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.Dimension;
25
import java.awt.EventQueue;
26
import java.awt.Frame;
27
import java.awt.Point;
28
import java.awt.Robot;
29
import java.awt.event.MouseAdapter;
30
import java.awt.event.MouseEvent;
31
32
public class FrameBorderCounter {
33
34
private static Frame frame;
35
private static Frame background;
36
private static Dimension size;
37
private static Point location;
38
private static Point entered;
39
40
public static void main(String[] args) throws Exception {
41
final Robot robot = new Robot();
42
EventQueue.invokeAndWait(new Runnable() {
43
public void run() {
44
robot.mouseMove(0, 0);
45
}
46
});
47
EventQueue.invokeAndWait(new Runnable() {
48
public void run() {
49
background = new Frame();
50
background.setBounds(100, 100, 300, 300);
51
background.addMouseListener(new MouseAdapter() {
52
@Override
53
public void mouseEntered(MouseEvent e) {
54
entered = e.getLocationOnScreen();
55
System.err.println("[ENTERED] : " + entered);
56
}
57
});
58
background.setVisible(true);
59
}
60
});
61
robot.waitForIdle();
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