3975N/A/*
3975N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3975N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3975N/A *
3975N/A * This code is free software; you can redistribute it and/or modify it
3975N/A * under the terms of the GNU General Public License version 2 only, as
3975N/A * published by the Free Software Foundation.
3975N/A *
3975N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3975N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3975N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3975N/A * version 2 for more details (a copy is included in the LICENSE file that
3975N/A * accompanied this code).
3975N/A *
3975N/A * You should have received a copy of the GNU General Public License version
3975N/A * 2 along with this work; if not, write to the Free Software Foundation,
3975N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3975N/A *
3975N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3975N/A * or visit www.oracle.com if you need additional information or have any
3975N/A * questions.
3975N/A */
3975N/A
3975N/A/*
3975N/A * @test
3975N/A * @bug 7034614
3975N/A * @summary Tests that TitledBorder does not modify Insets
3975N/A * @author Sergey Malenkov
3975N/A */
3975N/A
3975N/Aimport java.awt.Component;
3975N/Aimport java.awt.Graphics;
3975N/Aimport java.awt.Insets;
3975N/Aimport java.awt.image.BufferedImage;
3975N/Aimport javax.swing.border.Border;
3975N/Aimport javax.swing.border.TitledBorder;
3975N/A
3975N/Apublic class Test7034614 {
3975N/A
3975N/A public static void main(String[] args) {
3975N/A Graphics g = new BufferedImage(9, 9, 9).getGraphics();
3975N/A
3975N/A BrokenBorder broken = new BrokenBorder();
3975N/A TitledBorder titled = new TitledBorder(broken, broken.getClass().getName());
3975N/A
3975N/A Insets insets = (Insets) broken.getBorderInsets(broken).clone();
3975N/A titled.getBorderInsets(broken);
3975N/A broken.validate(insets);
3975N/A for (int i = 0; i < 10; i++) {
3975N/A titled.paintBorder(broken, g, 0, 0, i, i);
3975N/A broken.validate(insets);
3975N/A titled.getBaseline(broken, i, i);
3975N/A broken.validate(insets);
3975N/A }
3975N/A }
3975N/A
3975N/A private static class BrokenBorder extends Component implements Border {
3975N/A private Insets insets = new Insets(1, 2, 3, 4);
3975N/A
3975N/A private void validate(Insets insets) {
3975N/A if (!this.insets.equals(insets)) {
3975N/A throw new Error("unexpected change");
3975N/A }
3975N/A }
3975N/A
3975N/A public Insets getBorderInsets(Component c) {
3975N/A return this.insets;
3975N/A }
3975N/A
3975N/A public boolean isBorderOpaque() {
3975N/A return false;
3975N/A }
3975N/A
3975N/A public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
3975N/A }
3975N/A }
3975N/A}