1833N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1833N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1833N/A *
1833N/A * This code is free software; you can redistribute it and/or modify it
1833N/A * under the terms of the GNU General Public License version 2 only, as
1833N/A * published by the Free Software Foundation.
1833N/A *
1833N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1833N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1833N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1833N/A * version 2 for more details (a copy is included in the LICENSE file that
1833N/A * accompanied this code).
1833N/A *
1833N/A * You should have received a copy of the GNU General Public License version
1833N/A * 2 along with this work; if not, write to the Free Software Foundation,
1833N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1833N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1833N/A */
1833N/A
1833N/A/*
1833N/A * @test
1833N/A * @bug 6657026
1833N/A * @summary Tests constancy of borders
1833N/A * @author Sergey Malenkov
1833N/A */
1833N/A
1833N/Aimport java.awt.Insets;
1833N/Aimport javax.swing.border.Border;
1833N/Aimport javax.swing.plaf.metal.MetalBorders.ButtonBorder;
1833N/Aimport javax.swing.plaf.metal.MetalBorders.MenuBarBorder;
1833N/Aimport javax.swing.plaf.metal.MetalBorders.MenuItemBorder;
1833N/Aimport javax.swing.plaf.metal.MetalBorders.PopupMenuBorder;
1833N/A
1833N/Apublic class Test6657026 {
1833N/A
1833N/A private static final Insets NEGATIVE = new Insets(Integer.MIN_VALUE,
1833N/A Integer.MIN_VALUE,
1833N/A Integer.MIN_VALUE,
1833N/A Integer.MIN_VALUE);
1833N/A
1833N/A public static void main(String[] args) {
1833N/A new ButtonBorder() {{borderInsets = NEGATIVE;}};
1833N/A new MenuBarBorder() {{borderInsets = NEGATIVE;}};
1833N/A new MenuItemBorder() {{borderInsets = NEGATIVE;}};
1833N/A new PopupMenuBorder() {{borderInsets = NEGATIVE;}};
1833N/A
1833N/A test(create("ButtonBorder"));
1833N/A test(create("MenuBarBorder"));
1833N/A test(create("MenuItemBorder"));
1833N/A test(create("PopupMenuBorder"));
1833N/A
1833N/A test(create("Flush3DBorder"));
1833N/A test(create("InternalFrameBorder"));
1833N/A // NOT USED: test(create("FrameBorder"));
1833N/A // NOT USED: test(create("DialogBorder"));
1833N/A test(create("PaletteBorder"));
1833N/A test(create("OptionDialogBorder"));
1833N/A test(create("ScrollPaneBorder"));
1833N/A }
1833N/A
1833N/A private static Border create(String name) {
1833N/A try {
1833N/A name = "javax.swing.plaf.metal.MetalBorders$" + name;
1833N/A return (Border) Class.forName(name).newInstance();
1833N/A }
1833N/A catch (Exception exception) {
1833N/A throw new Error("unexpected exception", exception);
1833N/A }
1833N/A }
1833N/A
1833N/A private static void test(Border border) {
1833N/A Insets actual = border.getBorderInsets(null);
1833N/A if (NEGATIVE.equals(actual)) {
1833N/A throw new Error("unexpected insets in " + border.getClass());
1833N/A }
1833N/A Insets expected = (Insets) actual.clone();
1833N/A // modify
1833N/A actual.top++;
1833N/A actual.left++;
1833N/A actual.right++;
1833N/A actual.bottom++;
1833N/A // validate
1833N/A if (!expected.equals(border.getBorderInsets(null))) {
1833N/A throw new Error("shared insets in " + border.getClass());
1833N/A }
1833N/A }
1833N/A}