Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JList/TestOpaqueListTable.java
41152 views
1
/*
2
* Copyright (c) 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 javax.swing.JList;
25
import javax.swing.JTable;
26
import javax.swing.JToolTip;
27
import javax.swing.JTree;
28
import javax.swing.JViewport;
29
import javax.swing.LookAndFeel;
30
import javax.swing.SwingUtilities;
31
import javax.swing.UIManager;
32
import javax.swing.UnsupportedLookAndFeelException;
33
34
/**
35
* @test
36
* @bug 8253266 8264950
37
* @summary setUIProperty should work when opaque property is not set by
38
* client
39
* @key headful
40
* @run main TestOpaqueListTable
41
*/
42
43
public class TestOpaqueListTable {
44
45
public static void main(String[] args) throws Exception {
46
UIManager.LookAndFeelInfo[] installedLookAndFeels;
47
installedLookAndFeels = UIManager.getInstalledLookAndFeels();
48
for (UIManager.LookAndFeelInfo LF : installedLookAndFeels) {
49
try {
50
UIManager.setLookAndFeel(LF.getClassName());
51
SwingUtilities.invokeAndWait(() -> {
52
JList list = new JList();
53
JTable table = new JTable();
54
JTree tree = new JTree();
55
JToolTip toolTip = new JToolTip();
56
JViewport viewport = new JViewport();
57
String opaqueValue = new String(" ");
58
59
if (!list.isOpaque()) {
60
opaqueValue += "JList, ";
61
}
62
if (!table.isOpaque()) {
63
opaqueValue += "JTable, ";
64
}
65
if (!tree.isOpaque()) {
66
opaqueValue += "JTree, ";
67
}
68
if (!toolTip.isOpaque()) {
69
opaqueValue += "JToolTip, ";
70
71
}
72
if (!viewport.isOpaque()) {
73
opaqueValue += "JViewport, ";
74
}
75
76
if(!opaqueValue.equals(" ")) {
77
throw new RuntimeException("Default value of " +
78
"\"opaque\" property for " + opaqueValue
79
+ " is changed ");
80
}
81
82
LookAndFeel.installProperty(list, "opaque", false);
83
LookAndFeel.installProperty(table, "opaque", false);
84
LookAndFeel.installProperty(tree, "opaque", false);
85
LookAndFeel.installProperty(toolTip,"opaque",false);
86
LookAndFeel.installProperty(viewport,"opaque",false);
87
88
opaqueValue = " ";
89
if (list.isOpaque()) {
90
opaqueValue += "JList, ";
91
}
92
if (table.isOpaque()) {
93
opaqueValue += "JTable, ";
94
}
95
if (tree.isOpaque()) {
96
opaqueValue += "JTree, ";
97
}
98
if (toolTip.isOpaque()) {
99
opaqueValue += "JToolTip, ";
100
}
101
if (viewport.isOpaque()) {
102
opaqueValue += "JViewport, ";
103
}
104
if (!opaqueValue.equals(" ")) {
105
throw new RuntimeException(
106
"setUIProperty failed to clear " +
107
opaqueValue +" opaque" +
108
" when opaque is not set by client");
109
}
110
111
112
list.setOpaque(true);
113
table.setOpaque(true);
114
tree.setOpaque(true);
115
toolTip.setOpaque(true);
116
viewport.setOpaque(true);
117
118
LookAndFeel.installProperty(list,"opaque",false);
119
LookAndFeel.installProperty(table, "opaque", false);
120
LookAndFeel.installProperty(tree, "opaque", false);
121
LookAndFeel.installProperty(toolTip, "opaque", false);
122
LookAndFeel.installProperty(viewport, "opaque", false);
123
124
opaqueValue = " ";
125
126
if (!list.isOpaque()) {
127
opaqueValue += "JList";
128
}
129
if (!table.isOpaque()) {
130
opaqueValue += "JTable";
131
}
132
if (!tree.isOpaque()) {
133
opaqueValue += "JTree";
134
}
135
if (!toolTip.isOpaque()) {
136
opaqueValue += "JToolTip";
137
}
138
if (!viewport.isOpaque()) {
139
opaqueValue += "JViewport";
140
}
141
142
if (!opaqueValue.equals(" ")) {
143
throw new RuntimeException("" +
144
"setUIProperty cleared the " +opaqueValue +
145
" Opaque when opaque is set by client");
146
}
147
148
});
149
} catch (UnsupportedLookAndFeelException e) {
150
System.out.println("Note: LookAndFeel " + LF.getClassName()
151
+ " is not supported on this configuration");
152
}
153
}
154
}
155
}
156
157