Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Multiscreen/DeviceIdentificationTest/DeviceIdentificationTest.java
41153 views
1
/*
2
* Copyright (c) 2007, 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
* @test
25
* @bug 6614214 8198613
26
* @summary Verifies that we enter the fs mode on the correct screen.
27
* Here is how to test: start the test on on a multi-screen system.
28
* Verify that the display is correctly tracked by dragging the frame back
29
* and forth between screens. Then verify that the correct device enters
30
* the full-screen mode - when "Enter FS mode" is pressed it should enter on
31
* the device where the frame is.
32
*
33
* Then change the order of the monitors in the DisplayProperties dialog,
34
* (while the app is running) and see that it still works.
35
* Restart the app, verify again.
36
*
37
* Now change the primary monitor on the system and verify with the
38
* app running, as well as after restarting it that we still enter the
39
* fs mode on the right device.
40
*
41
* @run main/manual/othervm DeviceIdentificationTest
42
* @run main/manual/othervm -Dsun.java2d.noddraw=true DeviceIdentificationTest
43
*/
44
45
import java.awt.Button;
46
import java.awt.Color;
47
import java.awt.Frame;
48
import java.awt.Graphics;
49
import java.awt.GraphicsConfiguration;
50
import java.awt.GraphicsDevice;
51
import java.awt.GraphicsEnvironment;
52
import java.awt.Panel;
53
import java.awt.event.ActionEvent;
54
import java.awt.event.ActionListener;
55
import java.awt.event.ComponentAdapter;
56
import java.awt.event.ComponentEvent;
57
import java.awt.event.MouseAdapter;
58
import java.awt.event.MouseEvent;
59
import java.awt.event.WindowAdapter;
60
import java.awt.event.WindowEvent;
61
62
public class DeviceIdentificationTest {
63
64
public static void main(String args[]) {
65
final Frame f = new Frame("DeviceIdentificationTest");
66
f.addWindowListener(new WindowAdapter() {
67
public void windowClosing(WindowEvent e) {
68
f.dispose();
69
}
70
});
71
f.addComponentListener(new ComponentAdapter() {
72
public void componentMoved(ComponentEvent e) {
73
f.setTitle("Currently on: "+
74
f.getGraphicsConfiguration().getDevice());
75
}
76
});
77
78
Panel p = new Panel();
79
Button b = new Button("Print Current Devices");
80
b.addActionListener(new ActionListener() {
81
public void actionPerformed(ActionEvent e) {
82
GraphicsDevice gds[] =
83
GraphicsEnvironment.getLocalGraphicsEnvironment().
84
getScreenDevices();
85
int i = 0;
86
System.err.println("--- Devices: ---");
87
for (GraphicsDevice gd : gds) {
88
System.err.println("Device["+i+"]= "+ gd);
89
System.err.println(" bounds = "+
90
gd.getDefaultConfiguration().getBounds());
91
i++;
92
}
93
System.err.println("-------------------");
94
}
95
});
96
p.add(b);
97
98
b = new Button("Print My Device");
99
b.addActionListener(new ActionListener() {
100
public void actionPerformed(ActionEvent e) {
101
GraphicsConfiguration gc = f.getGraphicsConfiguration();
102
GraphicsDevice gd = gc.getDevice();
103
System.err.println("--- My Device ---");
104
System.err.println("Device = "+ gd);
105
System.err.println(" bounds = "+
106
gd.getDefaultConfiguration().getBounds());
107
}
108
});
109
p.add(b);
110
111
b = new Button("Create FS Frame on my Device");
112
b.addActionListener(new ActionListener() {
113
public void actionPerformed(ActionEvent e) {
114
GraphicsConfiguration gc = f.getGraphicsConfiguration();
115
final GraphicsDevice gd = gc.getDevice();
116
System.err.println("--- Creating FS Frame on Device ---");
117
System.err.println("Device = "+ gd);
118
System.err.println(" bounds = "+
119
gd.getDefaultConfiguration().getBounds());
120
final Frame fsf = new Frame("Full-screen Frame on dev"+gd, gc) {
121
public void paint(Graphics g) {
122
g.setColor(Color.green);
123
g.fillRect(0, 0, getWidth(), getHeight());
124
g.setColor(Color.red);
125
g.drawString("FS on device: "+gd, 200, 200);
126
g.drawString("Click to exit Full-screen.", 200, 250);
127
}
128
};
129
fsf.setUndecorated(true);
130
fsf.addMouseListener(new MouseAdapter() {
131
public void mouseClicked(MouseEvent e) {
132
gd.setFullScreenWindow(null);
133
fsf.dispose();
134
}
135
});
136
gd.setFullScreenWindow(fsf);
137
}
138
});
139
p.add(b);
140
f.add("North", p);
141
142
p = new Panel();
143
b = new Button("Test Passed");
144
b.setBackground(Color.green);
145
b.addActionListener(new ActionListener() {
146
public void actionPerformed(ActionEvent e) {
147
System.out.println("Test Passed");
148
f.dispose();
149
}
150
});
151
p.add(b);
152
b = new Button("Test Failed");
153
b.setBackground(Color.red);
154
b.addActionListener(new ActionListener() {
155
public void actionPerformed(ActionEvent e) {
156
System.out.println("Test FAILED");
157
f.dispose();
158
throw new RuntimeException("Test FAILED");
159
}
160
});
161
p.add(b);
162
f.add("South", p);
163
164
f.pack();
165
f.setVisible(true);
166
}
167
}
168
169