Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/GroupLayout/7071166/bug7071166.java
38918 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 707116626* @summary LayoutStyle.getPreferredGap() - IAE is expected but not thrown27* @author Pavel Porvatov28*/2930import javax.swing.*;31import static javax.swing.SwingConstants.*;32import java.awt.*;3334public class bug7071166 {35private static final int[] POSITIONS = {NORTH, EAST, SOUTH, WEST, // valid positions36NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST, 123, -456}; // invalid positions3738public static void main(String[] args) throws Exception {39for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {40UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());4142System.out.println("LookAndFeel: " + lookAndFeelInfo.getName());4344SwingUtilities.invokeAndWait(new Runnable() {45public void run() {46LayoutStyle layoutStyle = LayoutStyle.getInstance();4748System.out.println("LayoutStyle: " + layoutStyle);4950for (int i = 0; i < POSITIONS.length; i++) {51int position = POSITIONS[i];5253try {54layoutStyle.getPreferredGap(new JButton(), new JButton(),55LayoutStyle.ComponentPlacement.RELATED, position, new Container());5657if (i > 3) {58throw new RuntimeException("IllegalArgumentException is not thrown for position " +59position);60}61} catch (IllegalArgumentException e) {62if (i <= 3) {63throw new RuntimeException("IllegalArgumentException is thrown for position " +64position);65}66}67}68}69});7071System.out.println("passed");72}73}74}757677