5302N/A/*
5302N/A * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
5302N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5302N/A *
5302N/A * This code is free software; you can redistribute it and/or modify it
5302N/A * under the terms of the GNU General Public License version 2 only, as
5302N/A * published by the Free Software Foundation.
5302N/A *
5302N/A * This code is distributed in the hope that it will be useful, but WITHOUT
5302N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5302N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5302N/A * version 2 for more details (a copy is included in the LICENSE file that
5302N/A * accompanied this code).
5302N/A *
5302N/A * You should have received a copy of the GNU General Public License version
5302N/A * 2 along with this work; if not, write to the Free Software Foundation,
5302N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5302N/A *
5302N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5302N/A * or visit www.oracle.com if you need additional information or have any
5302N/A * questions.
5302N/A */
5302N/A
5302N/A/*
5302N/A * Portions Copyright (c) 2012 IBM Corporation
5302N/A */
5302N/A
5302N/A/*
5302N/A @test
5302N/A @bug 7170655
5302N/A @summary Frame size does not change after changing font
5302N/A @author Jonathan Lu
5302N/A @library ../../regtesthelpers
5302N/A @build Util
5302N/A @run main ResizeAfterSetFont
5302N/A */
5302N/A
5302N/Aimport java.awt.*;
5302N/Aimport test.java.awt.regtesthelpers.Util;
5302N/A
5302N/Apublic class ResizeAfterSetFont {
5302N/A
5302N/A public static void main(String[] args) throws Exception {
5302N/A Frame frame = new Frame("bug7170655");
5302N/A frame.setLayout(new BorderLayout());
5302N/A frame.setBackground(Color.LIGHT_GRAY);
5302N/A
5302N/A Panel panel = new Panel();
5302N/A panel.setLayout(new GridLayout(0, 1, 1, 1));
5302N/A
5302N/A Label label = new Label("Test Label");
5302N/A label.setBackground(Color.white);
5302N/A label.setForeground(Color.RED);
5302N/A label.setFont(new Font("Dialog", Font.PLAIN, 12));
5302N/A
5302N/A panel.add(label);
5302N/A frame.add(panel, "South");
5302N/A frame.pack();
5302N/A frame.setVisible(true);
5302N/A
5302N/A Util.waitForIdle(null);
5302N/A
5302N/A Dimension dimBefore = frame.getSize();
5302N/A label.setFont(new Font("Dialog", Font.PLAIN, 24));
5302N/A
5302N/A frame.validate();
5302N/A frame.pack();
5302N/A Dimension dimAfter = frame.getSize();
5302N/A
5302N/A if (dimBefore.equals(dimAfter)) {
5302N/A throw new Exception(
5302N/A "Frame size does not change after Label.setFont()!");
5302N/A }
5302N/A }
5302N/A}