Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JTabbedPane/4310381/bug4310381.java
38855 views
/*1* Copyright (c) 2012, 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* Portions Copyright (c) 2012 IBM Corporation25*/2627/*28* @test29* @bug 431038130* @summary Text in multi-row/col JTabbedPane tabs can be truncated/clipped31* @author Charles Lee32@run applet/manual=yesno bug4310381.html33*/343536import javax.swing.*;37import java.awt.*;38import java.lang.reflect.InvocationTargetException;3940public class bug4310381 extends JApplet {41public static void main(String[] args) throws Exception {42SwingUtilities.invokeLater(new Runnable() {43public void run() {44JFrame frame = new JFrame();4546frame.setContentPane(createContentPane());47frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);48frame.setSize(150, 200);49frame.setLocationRelativeTo(null);5051frame.setVisible(true);5253}54});55}5657@Override58public void init() {59try {60SwingUtilities.invokeAndWait(new Runnable() {61@Override62public void run() {63setContentPane(createContentPane());64}65});66} catch (InterruptedException | InvocationTargetException e) {67throw new RuntimeException(e);68}69}7071private static Container createContentPane() {72JTabbedPane tab = new JTabbedPane();73String a2z = "abcdefghijklmnopqrstuvwxyz";7475tab.addTab("0" + a2z + a2z, new JLabel("0"));76tab.addTab("1" + a2z, new JLabel("1" + a2z));77tab.addTab("2" + a2z, new JLabel("2" + a2z));78tab.addTab("3", new JLabel("3" + a2z)); // The last tab in Metal isn't truncated, that's ok7980return tab;81}82}838485