Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JTableHeader/6442918/bug6442918a.java
41153 views
1
/*
2
* Copyright (c) 2015, 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 6442918 8005914
26
@summary Ensures that empty table headers do not show "..."
27
@author Shannon Hickey
28
@library ../../regtesthelpers
29
@build Util
30
@run main/manual bug6442918a
31
@requires os.family == "windows"
32
*/
33
34
import java.awt.BorderLayout;
35
import java.awt.Dimension;
36
import javax.swing.JDialog;
37
import javax.swing.JFrame;
38
import javax.swing.JPanel;
39
import javax.swing.JScrollPane;
40
import javax.swing.JTable;
41
import javax.swing.JTextArea;
42
import javax.swing.SwingUtilities;
43
import javax.swing.UIManager;
44
import javax.swing.table.DefaultTableCellRenderer;
45
46
47
public class bug6442918a {
48
49
public static void main(String[] args) throws Throwable, Exception {
50
SwingUtilities.invokeAndWait(new Runnable() {
51
public void run() {
52
try {
53
UIManager.setLookAndFeel("com.sun.java.swing.plaf"
54
+ ".windows.WindowsLookAndFeel");
55
} catch (Exception e) {
56
// test is for Windows look and feel
57
throw new RuntimeException("Test is only for WLaF."
58
+ e.getMessage());
59
}
60
runTest();
61
}
62
});
63
}
64
65
private static void runTest() {
66
JDialog dialog = Util
67
.createModalDialogWithPassFailButtons("Empty header showing \"...\"");
68
String[] columnNames = {"", "", "", "", "Testing"};
69
String[][] data = {{"1", "2", "3", "4", "5"}};
70
JTable table = new JTable(data, columnNames);
71
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
72
int tableCellWidth = renderer.getFontMetrics(renderer.getFont())
73
.stringWidth("test");
74
table.setPreferredScrollableViewportSize(new Dimension(
75
5 * tableCellWidth, 50));
76
JPanel p = new JPanel();
77
p.add(new JScrollPane(table));
78
dialog.add(p, BorderLayout.NORTH);
79
JTextArea area = new JTextArea();
80
String txt = "\nInstructions:\n\n";
81
txt += "Only the last column header should show \"...\".";
82
area.setText(txt);
83
dialog.add(new JScrollPane(area), BorderLayout.CENTER);
84
dialog.pack();
85
dialog.setVisible(true);
86
}
87
}
88
89