Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JOptionPane/8024926/bug8024926.java
41153 views
1
/*
2
* Copyright (c) 2013, 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
import java.awt.BorderLayout;
24
import java.awt.Dialog;
25
import java.awt.EventQueue;
26
import java.awt.Frame;
27
import java.awt.TextArea;
28
import javax.swing.JApplet;
29
import javax.swing.JOptionPane;
30
31
import jdk.test.lib.Platform;
32
33
/**
34
* @test
35
* @bug 8024926 8040279
36
* @summary [macosx] AquaIcon HiDPI support
37
* @author Alexander Scherbatiy
38
* @library /test/lib
39
* @build jdk.test.lib.Platform
40
* @run applet/manual=yesno bug8024926.html
41
*/
42
public class bug8024926 extends JApplet {
43
//Declare things used in the test, like buttons and labels here
44
45
public void init() {
46
//Create instructions for the user here, as well as set up
47
// the environment -- set the layout manager, add buttons,
48
// etc.
49
this.setLayout(new BorderLayout());
50
51
52
if (Platform.isOSX()) {
53
String[] instructions = {
54
"Verify that high resolution system icons are used"
55
+ " in JOptionPane on HiDPI displays.",
56
"1) Run the test on Retina display or enable the Quartz Debug"
57
+ " and select the screen resolution with (HiDPI) label",
58
"2) Check that the error icon on the JOptionPane is smooth",
59
"If so, press PASS, else press FAIL."
60
};
61
Sysout.createDialogWithInstructions(instructions);
62
63
} else {
64
String[] instructions = {
65
"This test is not applicable to the current platform. Press PASS."
66
};
67
Sysout.createDialogWithInstructions(instructions);
68
}
69
70
71
}//End init()
72
73
public void start() {
74
//Get things going. Request focus, set size, et cetera
75
setSize(200, 200);
76
setVisible(true);
77
validate();
78
EventQueue.invokeLater(new Runnable() {
79
80
public void run() {
81
createAndShowGUI();
82
}
83
});
84
}// start()
85
86
//The rest of this class is the actions which perform the test...
87
//Use Sysout.println to communicate with the user NOT System.out!!
88
//Sysout.println ("Something Happened!");
89
private static void createAndShowGUI() {
90
JOptionPane.showMessageDialog(null,
91
"Icons should have high resolution.",
92
"High resolution icon test.",
93
JOptionPane.ERROR_MESSAGE);
94
}
95
}// class BlockedWindowTest
96
97
/* Place other classes related to the test after this line */
98
/**
99
* **************************************************
100
* Standard Test Machinery DO NOT modify anything below -- it's a standard chunk
101
* of code whose purpose is to make user interaction uniform, and thereby make
102
* it simpler to read and understand someone else's test.
103
* **************************************************
104
*/
105
/**
106
* This is part of the standard test machinery. It creates a dialog (with the
107
* instructions), and is the interface for sending text messages to the user. To
108
* print the instructions, send an array of strings to Sysout.createDialog
109
* WithInstructions method. Put one line of instructions per array entry. To
110
* display a message for the tester to see, simply call Sysout.println with the
111
* string to be displayed. This mimics System.out.println but works within the
112
* test harness as well as standalone.
113
*/
114
class Sysout {
115
116
private static TestDialog dialog;
117
118
public static void createDialogWithInstructions(String[] instructions) {
119
dialog = new TestDialog(new Frame(), "Instructions");
120
dialog.printInstructions(instructions);
121
dialog.setVisible(true);
122
println("Any messages for the tester will display here.");
123
}
124
125
public static void createDialog() {
126
dialog = new TestDialog(new Frame(), "Instructions");
127
String[] defInstr = {"Instructions will appear here. ", ""};
128
dialog.printInstructions(defInstr);
129
dialog.setVisible(true);
130
println("Any messages for the tester will display here.");
131
}
132
133
public static void printInstructions(String[] instructions) {
134
dialog.printInstructions(instructions);
135
}
136
137
public static void println(String messageIn) {
138
dialog.displayMessage(messageIn);
139
}
140
}// Sysout class
141
142
/**
143
* This is part of the standard test machinery. It provides a place for the test
144
* instructions to be displayed, and a place for interactive messages to the
145
* user to be displayed. To have the test instructions displayed, see Sysout. To
146
* have a message to the user be displayed, see Sysout. Do not call anything in
147
* this dialog directly.
148
*/
149
class TestDialog extends Dialog {
150
151
TextArea instructionsText;
152
TextArea messageText;
153
int maxStringLength = 80;
154
155
//DO NOT call this directly, go through Sysout
156
public TestDialog(Frame frame, String name) {
157
super(frame, name);
158
int scrollBoth = TextArea.SCROLLBARS_BOTH;
159
instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
160
add("North", instructionsText);
161
162
messageText = new TextArea("", 5, maxStringLength, scrollBoth);
163
add("Center", messageText);
164
165
pack();
166
167
setVisible(true);
168
}// TestDialog()
169
170
//DO NOT call this directly, go through Sysout
171
public void printInstructions(String[] instructions) {
172
//Clear out any current instructions
173
instructionsText.setText("");
174
175
//Go down array of instruction strings
176
177
String printStr, remainingStr;
178
for (int i = 0; i < instructions.length; i++) {
179
//chop up each into pieces maxSringLength long
180
remainingStr = instructions[ i];
181
while (remainingStr.length() > 0) {
182
//if longer than max then chop off first max chars to print
183
if (remainingStr.length() >= maxStringLength) {
184
//Try to chop on a word boundary
185
int posOfSpace = remainingStr.lastIndexOf(' ', maxStringLength - 1);
186
187
if (posOfSpace <= 0) {
188
posOfSpace = maxStringLength - 1;
189
}
190
191
printStr = remainingStr.substring(0, posOfSpace + 1);
192
remainingStr = remainingStr.substring(posOfSpace + 1);
193
} //else just print
194
else {
195
printStr = remainingStr;
196
remainingStr = "";
197
}
198
199
instructionsText.append(printStr + "\n");
200
201
}// while
202
203
}// for
204
205
}//printInstructions()
206
207
//DO NOT call this directly, go through Sysout
208
public void displayMessage(String messageIn) {
209
messageText.append(messageIn + "\n");
210
System.out.println(messageIn);
211
}
212
}// TestDialog class
213
214