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