4356N/A/*
4356N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4356N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4356N/A *
4356N/A * This code is free software; you can redistribute it and/or modify it
4356N/A * under the terms of the GNU General Public License version 2 only, as
4356N/A * published by the Free Software Foundation.
4356N/A *
4356N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4356N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4356N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4356N/A * version 2 for more details (a copy is included in the LICENSE file that
4356N/A * accompanied this code).
4356N/A *
4356N/A * You should have received a copy of the GNU General Public License version
4356N/A * 2 along with this work; if not, write to the Free Software Foundation,
4356N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4356N/A *
4356N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4356N/A * or visit www.oracle.com if you need additional information or have any
4356N/A * questions.
4356N/A */
4356N/A
4356N/A/*
4356N/A * @test
4356N/A * @bug 7071166
4356N/A * @summary LayoutStyle.getPreferredGap() - IAE is expected but not thrown
4356N/A * @author Pavel Porvatov
4356N/A */
4356N/A
4356N/Aimport javax.swing.*;
4356N/Aimport static javax.swing.SwingConstants.*;
4356N/Aimport java.awt.*;
4356N/A
4356N/Apublic class bug7071166 {
4356N/A private static final int[] POSITIONS = {NORTH, EAST, SOUTH, WEST, // valid positions
4356N/A NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST, 123, -456}; // invalid positions
4356N/A
4356N/A public static void main(String[] args) throws Exception {
4356N/A for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
4356N/A UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
4356N/A
4356N/A System.out.println("LookAndFeel: " + lookAndFeelInfo.getName());
4356N/A
4356N/A SwingUtilities.invokeAndWait(new Runnable() {
4356N/A public void run() {
4356N/A LayoutStyle layoutStyle = LayoutStyle.getInstance();
4356N/A
4356N/A System.out.println("LayoutStyle: " + layoutStyle);
4356N/A
4356N/A for (int i = 0; i < POSITIONS.length; i++) {
4356N/A int position = POSITIONS[i];
4356N/A
4356N/A try {
4356N/A layoutStyle.getPreferredGap(new JButton(), new JButton(),
4356N/A LayoutStyle.ComponentPlacement.RELATED, position, new Container());
4356N/A
4356N/A if (i > 3) {
4356N/A throw new RuntimeException("IllegalArgumentException is not thrown for position " +
4356N/A position);
4356N/A }
4356N/A } catch (IllegalArgumentException e) {
4356N/A if (i <= 3) {
4356N/A throw new RuntimeException("IllegalArgumentException is thrown for position " +
4356N/A position);
4356N/A }
4356N/A }
4356N/A }
4356N/A }
4356N/A });
4356N/A
4356N/A System.out.println("passed");
4356N/A }
4356N/A }
4356N/A}