Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JMenuItem/8031573/bug8031573.java
41153 views
1
/*
2
* Copyright (c) 2016, 2021, 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.BorderLayout;
25
import java.awt.FlowLayout;
26
import java.awt.event.WindowAdapter;
27
import java.awt.event.WindowEvent;
28
import java.util.concurrent.CountDownLatch;
29
import java.util.concurrent.TimeUnit;
30
import javax.swing.JButton;
31
import javax.swing.JCheckBoxMenuItem;
32
import javax.swing.JFrame;
33
import javax.swing.JMenu;
34
import javax.swing.JMenuBar;
35
import javax.swing.JMenuItem;
36
import javax.swing.JPanel;
37
import javax.swing.JTextArea;
38
import javax.swing.JTextField;
39
import javax.swing.SwingUtilities;
40
import javax.swing.UIManager;
41
import javax.swing.text.JTextComponent;
42
43
/* @test
44
* @bug 8031573 8040279 8143064
45
* @summary [macosx] Checkmarks of JCheckBoxMenuItems aren't rendered
46
* in high resolution on Retina
47
* @run main/manual bug8031573
48
*/
49
50
public class bug8031573 {
51
52
private static volatile JFrame frame;
53
private static volatile boolean passed = false;
54
private static final CountDownLatch latch = new CountDownLatch(1);
55
56
public static final String INSTRUCTIONS = "INSTRUCTIONS:\n\n"
57
+ "Verify that high resolution system icons are used for JCheckBoxMenuItem on HiDPI displays.\n"
58
+ "If the display does not support HiDPI mode press PASS.\n"
59
+ "1. Run the test on HiDPI Display.\n"
60
+ "2. Open the Menu.\n"
61
+ "3. Check that the icon on the JCheckBoxMenuItem is smooth.\n"
62
+ " If so, press PASS, else press FAIL.\n";
63
64
public static void main(String args[]) throws Exception {
65
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
66
try {
67
SwingUtilities.invokeAndWait(() -> createTestGUI());
68
69
if (!latch.await(5, TimeUnit.MINUTES)) {
70
throw new RuntimeException("Test has timed out!");
71
}
72
if (!passed) {
73
throw new RuntimeException("Test failed!");
74
}
75
} finally {
76
SwingUtilities.invokeAndWait(() -> {
77
if (frame != null) {
78
frame.dispose();
79
}
80
});
81
}
82
}
83
84
private static void createTestGUI() {
85
frame = new JFrame("bug8031573");
86
JMenuBar bar = new JMenuBar();
87
JMenu menu = new JMenu("Menu");
88
JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem("JCheckBoxMenuItem");
89
checkBoxMenuItem.setSelected(true);
90
menu.add(checkBoxMenuItem);
91
bar.add(menu);
92
frame.setJMenuBar(bar);
93
94
JPanel panel = new JPanel(new BorderLayout());
95
JTextComponent textComponent = new JTextArea(INSTRUCTIONS);
96
textComponent.setEditable(false);
97
panel.add(textComponent, BorderLayout.CENTER);
98
99
JPanel buttonsPanel = new JPanel(new FlowLayout());
100
JButton passButton = new JButton("Pass");
101
passButton.addActionListener((e) -> {
102
System.out.println("Test passed!");
103
passed = true;
104
latch.countDown();
105
});
106
JButton failsButton = new JButton("Fail");
107
failsButton.addActionListener((e) -> {
108
passed = false;
109
latch.countDown();
110
});
111
112
buttonsPanel.add(passButton);
113
buttonsPanel.add(failsButton);
114
panel.add(buttonsPanel, BorderLayout.SOUTH);
115
116
frame.getContentPane().add(panel);
117
118
frame.addWindowListener(new WindowAdapter() {
119
@Override
120
public void windowClosing(WindowEvent e) {
121
latch.countDown();
122
}
123
});
124
frame.pack();
125
frame.setLocationRelativeTo(null);
126
frame.setVisible(true);
127
}
128
}
129
130