Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JTable/4235420/bug4235420.java
41153 views
1
/*
2
* Copyright (c) 2012, 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 4235420
26
@summary Tests that JTable delays creating Renderers and Editors
27
@author Peter Zhelezniakov
28
*/
29
30
import javax.swing.*;
31
import javax.swing.table.TableCellEditor;
32
import javax.swing.table.TableCellRenderer;
33
import java.util.Date;
34
import java.util.HashMap;
35
import java.util.Map;
36
37
public class bug4235420 {
38
39
public static void main(String[] argv) throws Exception {
40
for (UIManager.LookAndFeelInfo LF :
41
UIManager.getInstalledLookAndFeels()) {
42
try {
43
UIManager.setLookAndFeel(LF.getClassName());
44
} catch (UnsupportedLookAndFeelException ignored) {
45
System.out.println("Unsupported L&F: " + LF.getClassName());
46
} catch (ClassNotFoundException | InstantiationException
47
| IllegalAccessException e) {
48
throw new RuntimeException(e);
49
}
50
System.out.println("Testing L&F: " + LF.getClassName());
51
52
if ("Nimbus".equals(UIManager.getLookAndFeel().getName()) ||
53
"GTK".equals(UIManager.getLookAndFeel().getName())) {
54
System.out.println("The test is skipped for Nimbus and GTK");
55
56
continue;
57
}
58
59
SwingUtilities.invokeAndWait(new Runnable() {
60
@Override
61
public void run() {
62
Table table = new Table();
63
64
table.test();
65
}
66
});
67
}
68
}
69
70
private static class Table extends JTable {
71
public void test() {
72
// Renderers
73
Class[] rendererClasses = {Object.class, Number.class, Date.class, ImageIcon.class, Boolean.class};
74
75
Map copy = new HashMap(defaultRenderersByColumnClass);
76
77
for (Class rendererClass : rendererClasses) {
78
Object obj = copy.get(rendererClass);
79
80
if (obj instanceof TableCellRenderer) {
81
throw new Error("Failed: TableCellRenderer created for " +
82
rendererClass.getClass().getName());
83
}
84
}
85
86
// Editors
87
Class[] editorClasses = {Object.class, Number.class, Boolean.class};
88
89
copy = new HashMap(defaultEditorsByColumnClass);
90
91
for (Class editorClass : editorClasses) {
92
Object obj = copy.get(editorClass);
93
94
if (obj instanceof TableCellEditor) {
95
throw new Error("Failed: TableCellEditor created for " +
96
editorClass.getClass().getName());
97
}
98
}
99
}
100
}
101
}
102
103