|
1 /* |
|
2 * Copyright (c) 2011, 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 /* |
|
25 * @test |
|
26 * @bug 6416920 |
|
27 * @summary Ensures that selected tab is painted properly in the scroll tab layout |
|
28 * under WindowsLookAndFeel in Windows' "Windows XP" theme. |
|
29 * @author Mikhail Lapshin |
|
30 * @run main bug6416920 |
|
31 */ |
|
32 |
|
33 import javax.swing.plaf.basic.BasicTabbedPaneUI; |
|
34 import javax.swing.JTabbedPane; |
|
35 import javax.swing.SwingConstants; |
|
36 import java.awt.Rectangle; |
|
37 import java.awt.Insets; |
|
38 import sun.awt.OSInfo; |
|
39 |
|
40 public class bug6416920 extends BasicTabbedPaneUI { |
|
41 public AccessibleTabbedPaneLayout layout = new AccessibleTabbedPaneLayout(); |
|
42 |
|
43 public static void main(String[] args) { |
|
44 |
|
45 if(OSInfo.getOSType() != OSInfo.OSType.WINDOWS){ |
|
46 return; |
|
47 } |
|
48 |
|
49 bug6416920 test = new bug6416920(); |
|
50 test.layout.padSelectedTab(SwingConstants.TOP, 0); |
|
51 if (test.rects[0].width < 0) { |
|
52 throw new RuntimeException("A selected tab isn't painted properly " + |
|
53 "in the scroll tab layout under WindowsLookAndFeel " + |
|
54 "in Windows' \"Windows XP\" theme."); |
|
55 } |
|
56 } |
|
57 |
|
58 public bug6416920() { |
|
59 super(); |
|
60 |
|
61 // Set parameters for the padSelectedTab() method |
|
62 selectedTabPadInsets = new Insets(0, 0, 0, 0); |
|
63 |
|
64 tabPane = new JTabbedPane(); |
|
65 tabPane.setSize(100, 0); |
|
66 tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); |
|
67 |
|
68 rects = new Rectangle[1]; |
|
69 rects[0] = new Rectangle(150, 0, 0, 0); |
|
70 } |
|
71 |
|
72 public class AccessibleTabbedPaneLayout extends BasicTabbedPaneUI.TabbedPaneLayout { |
|
73 public void padSelectedTab(int tabPlacement, int selectedIndex) { |
|
74 super.padSelectedTab(tabPlacement, selectedIndex); |
|
75 } |
|
76 } |
|
77 } |