Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JTable/Test6888156.java
41152 views
1
/*
2
* Copyright (c) 2007, 2010, 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 6888156
26
@summary Tests table column of class Icon.class with Synth LAF
27
@author Peter Zhelezniakov
28
@run main Test6888156
29
*/
30
31
import java.awt.Component;
32
import java.awt.Graphics;
33
import java.awt.image.BufferedImage;
34
import javax.swing.*;
35
import javax.swing.table.AbstractTableModel;
36
import javax.swing.table.TableModel;
37
38
public class Test6888156 {
39
private JTable table;
40
private Icon ICON = new Icon() {
41
@Override public int getIconWidth() {
42
return 24;
43
}
44
45
@Override public int getIconHeight() {
46
return 24;
47
}
48
49
@Override public void paintIcon(Component c, Graphics g, int w, int h) {
50
}
51
};
52
53
public Test6888156() {
54
TableModel model = new AbstractTableModel() {
55
@Override public int getRowCount() {
56
return 3;
57
}
58
59
@Override public int getColumnCount() {
60
return 2;
61
}
62
63
@Override public Object getValueAt(int rowIndex, int columnIndex) {
64
return (columnIndex == 1 ? ICON : 4);
65
}
66
67
@Override public Class<?> getColumnClass(int columnIndex) {
68
return (columnIndex == 1 ? Icon.class : int.class);
69
}
70
};
71
table = new JTable(model);
72
}
73
74
public void test(final String laf) throws Exception {
75
SwingUtilities.invokeAndWait(new Runnable() {
76
@Override public void run() {
77
try {
78
System.out.println(laf);
79
UIManager.setLookAndFeel(laf);
80
} catch (Exception e) {
81
System.err.println(laf + " is unsupported; continuing");
82
return;
83
}
84
SwingUtilities.updateComponentTreeUI(table);
85
table.setSize(100, 100);
86
table.paint(
87
new BufferedImage(100, 100, BufferedImage.OPAQUE).
88
getGraphics());
89
}
90
});
91
}
92
93
public static void main(String[] args) throws Exception {
94
Test6888156 t = new Test6888156();
95
t.test("javax.swing.plaf.nimbus.NimbusLookAndFeel");
96
t.test("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
97
for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
98
t.test(laf.getClassName());
99
}
100
}
101
}
102
103