Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JTabbedPane/6416920/bug6416920.java
38855 views
/*1* Copyright (c) 2011, 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* @run main bug641692030*/3132import javax.swing.plaf.basic.BasicTabbedPaneUI;33import javax.swing.JTabbedPane;34import javax.swing.SwingConstants;35import java.awt.Rectangle;36import java.awt.Insets;37import sun.awt.OSInfo;3839public class bug6416920 extends BasicTabbedPaneUI {40public AccessibleTabbedPaneLayout layout = new AccessibleTabbedPaneLayout();4142public static void main(String[] args) {4344if(OSInfo.getOSType() != OSInfo.OSType.WINDOWS){45return;46}4748bug6416920 test = new bug6416920();49test.layout.padSelectedTab(SwingConstants.TOP, 0);50if (test.rects[0].width < 0) {51throw new RuntimeException("A selected tab isn't painted properly " +52"in the scroll tab layout under WindowsLookAndFeel " +53"in Windows' \"Windows XP\" theme.");54}55}5657public bug6416920() {58super();5960// Set parameters for the padSelectedTab() method61selectedTabPadInsets = new Insets(0, 0, 0, 0);6263tabPane = new JTabbedPane();64tabPane.setSize(100, 0);65tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);6667rects = new Rectangle[1];68rects[0] = new Rectangle(150, 0, 0, 0);69}7071public class AccessibleTabbedPaneLayout extends BasicTabbedPaneUI.TabbedPaneLayout {72public void padSelectedTab(int tabPlacement, int selectedIndex) {73super.padSelectedTab(tabPlacement, selectedIndex);74}75}76}777879