Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JTabbedPane/7010561/bug7010561.java
38855 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
import javax.swing.*;
25
import javax.swing.plaf.basic.BasicTabbedPaneUI;
26
import javax.swing.plaf.synth.SynthLookAndFeel;
27
import java.lang.reflect.Method;
28
29
/* @test
30
@bug 7010561
31
@summary Tab text position with Synth based LaF is different to Java 5/6
32
@author Pavel Porvatov
33
*/
34
public class bug7010561 {
35
private static int[] TAB_PLACEMENT = {
36
SwingConstants.BOTTOM,
37
SwingConstants.BOTTOM,
38
SwingConstants.TOP,
39
SwingConstants.TOP,
40
41
};
42
43
private static boolean[] IS_SELECTED = {
44
false,
45
true,
46
false,
47
true
48
};
49
50
private static int[] RETURN_VALUE = {
51
-1,
52
1,
53
1,
54
-1
55
};
56
57
public static void main(String[] args) throws Exception {
58
UIManager.setLookAndFeel(new SynthLookAndFeel());
59
60
SwingUtilities.invokeAndWait(new Runnable() {
61
@Override
62
public void run() {
63
JTabbedPane tabbedPane = new JTabbedPane();
64
65
tabbedPane.addTab("Tab 1", new JLabel("Tab 1"));
66
67
// Ensure internal TabbedPane fields are initialized
68
tabbedPane.doLayout();
69
70
BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI();
71
72
try {
73
Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class,
74
int.class, boolean.class);
75
76
method.setAccessible(true);
77
78
for (int i = 0; i < 4; i++) {
79
int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0,
80
IS_SELECTED[i])).intValue();
81
82
if (res != RETURN_VALUE[i]) {
83
throw new RuntimeException("Test bug7010561 failed on index " + i);
84
}
85
}
86
} catch (Exception e) {
87
throw new RuntimeException(e);
88
}
89
90
System.out.println("Test bug7010561 passed");
91
}
92
});
93
}
94
}
95
96