Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JTable/8031971/bug8031971.java
41154 views
1
/*
2
* Copyright (c) 2014, 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.util.Date;
24
import java.util.Hashtable;
25
import javax.swing.Icon;
26
import javax.swing.ImageIcon;
27
import javax.swing.JTable;
28
import javax.swing.SwingUtilities;
29
30
/**
31
* @test
32
* @bug 8031971 8039750
33
* @author Alexander Scherbatiy
34
* @summary Use only public methods in the SwingLazyValue
35
* @run main/othervm bug8031971
36
*/
37
public class bug8031971 {
38
39
static Object[][] RENDERERS = {
40
{Object.class, "javax.swing.table.DefaultTableCellRenderer$UIResource"},
41
{Number.class, "javax.swing.JTable$NumberRenderer"},
42
{Float.class, "javax.swing.JTable$DoubleRenderer"},
43
{Double.class, "javax.swing.JTable$DoubleRenderer"},
44
{Date.class, "javax.swing.JTable$DateRenderer"},
45
{Icon.class, "javax.swing.JTable$IconRenderer"},
46
{ImageIcon.class, "javax.swing.JTable$IconRenderer"},
47
{Boolean.class, "javax.swing.JTable$BooleanRenderer"}
48
};
49
50
static Object[][] EDITORS = {
51
{Object.class, "javax.swing.JTable$GenericEditor"},
52
{Number.class, "javax.swing.JTable$NumberEditor"},
53
{Boolean.class, "javax.swing.JTable$BooleanEditor"}
54
};
55
56
public static void main(String[] args) throws Exception {
57
58
SwingUtilities.invokeAndWait(() -> {
59
60
TestTable table = new TestTable();
61
test(table.getDefaultRenderersByColumnClass(), RENDERERS);
62
test(table.getDefaultEditorsByColumnClass(), EDITORS);
63
});
64
}
65
66
static void test(Hashtable table, Object[][] values) {
67
for (int i = 0; i < values.length; i++) {
68
test(table.get(values[i][0]), (String) values[i][1]);
69
}
70
}
71
72
static void test(Object obj, String className) {
73
if (!obj.getClass().getCanonicalName().equals(className.replace('$', '.'))) {
74
throw new RuntimeException("Wrong value!");
75
}
76
}
77
78
static class TestTable extends JTable {
79
80
Hashtable getDefaultRenderersByColumnClass() {
81
return defaultRenderersByColumnClass;
82
}
83
84
Hashtable getDefaultEditorsByColumnClass() {
85
return defaultEditorsByColumnClass;
86
}
87
}
88
}
89
90