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