Path: blob/master/test/jdk/javax/swing/JTabbedPane/6416920/bug6416920.java
41153 views
/*1* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 641692026* @summary Ensures that selected tab is painted properly in the scroll tab layout27* under WindowsLookAndFeel in Windows' "Windows XP" theme.28* @author Mikhail Lapshin29* @library /test/lib30* @build jdk.test.lib.Platform31* @run main bug641692032*/3334import javax.swing.plaf.basic.BasicTabbedPaneUI;35import javax.swing.JTabbedPane;36import javax.swing.SwingConstants;37import java.awt.Rectangle;38import java.awt.Insets;3940import jdk.test.lib.Platform;4142public class bug6416920 extends BasicTabbedPaneUI {43public AccessibleTabbedPaneLayout layout = new AccessibleTabbedPaneLayout();4445public static void main(String[] args) {4647if (!Platform.isWindows()) {48return;49}5051bug6416920 test = new bug6416920();52test.layout.padSelectedTab(SwingConstants.TOP, 0);53if (test.rects[0].width < 0) {54throw new RuntimeException("A selected tab isn't painted properly " +55"in the scroll tab layout under WindowsLookAndFeel " +56"in Windows' \"Windows XP\" theme.");57}58}5960public bug6416920() {61super();6263// Set parameters for the padSelectedTab() method64selectedTabPadInsets = new Insets(0, 0, 0, 0);6566tabPane = new JTabbedPane();67tabPane.setSize(100, 0);68tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);6970rects = new Rectangle[1];71rects[0] = new Rectangle(150, 0, 0, 0);72}7374public class AccessibleTabbedPaneLayout extends BasicTabbedPaneUI.TabbedPaneLayout {75public void padSelectedTab(int tabPlacement, int selectedIndex) {76super.padSelectedTab(tabPlacement, selectedIndex);77}78}79}808182