bug6416920.java revision 4545
0N/A/*
2362N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 6416920
0N/A * @summary Ensures that selected tab is painted properly in the scroll tab layout
0N/A * under WindowsLookAndFeel in Windows' "Windows XP" theme.
0N/A * @author Mikhail Lapshin
0N/A * @run main bug6416920
0N/A */
0N/A
0N/Aimport javax.swing.plaf.basic.BasicTabbedPaneUI;
0N/Aimport javax.swing.JTabbedPane;
0N/Aimport javax.swing.SwingConstants;
0N/Aimport java.awt.Rectangle;
0N/Aimport java.awt.Insets;
0N/Aimport sun.awt.OSInfo;
0N/A
0N/Apublic class bug6416920 extends BasicTabbedPaneUI {
0N/A public AccessibleTabbedPaneLayout layout = new AccessibleTabbedPaneLayout();
0N/A
0N/A public static void main(String[] args) {
0N/A
0N/A if(OSInfo.getOSType() != OSInfo.OSType.WINDOWS){
0N/A return;
0N/A }
0N/A
0N/A bug6416920 test = new bug6416920();
0N/A test.layout.padSelectedTab(SwingConstants.TOP, 0);
0N/A if (test.rects[0].width < 0) {
0N/A throw new RuntimeException("A selected tab isn't painted properly " +
0N/A "in the scroll tab layout under WindowsLookAndFeel " +
0N/A "in Windows' \"Windows XP\" theme.");
0N/A }
0N/A }
0N/A
0N/A public bug6416920() {
0N/A super();
0N/A
0N/A // Set parameters for the padSelectedTab() method
0N/A selectedTabPadInsets = new Insets(0, 0, 0, 0);
0N/A
0N/A tabPane = new JTabbedPane();
0N/A tabPane.setSize(100, 0);
0N/A tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
0N/A
0N/A rects = new Rectangle[1];
0N/A rects[0] = new Rectangle(150, 0, 0, 0);
0N/A }
0N/A
0N/A public class AccessibleTabbedPaneLayout extends BasicTabbedPaneUI.TabbedPaneLayout {
0N/A public void padSelectedTab(int tabPlacement, int selectedIndex) {
0N/A super.padSelectedTab(tabPlacement, selectedIndex);
0N/A }
0N/A }
0N/A}
0N/A