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