Path: blob/master/test/jdk/java/awt/Frame/ResizeAfterSetFont/ResizeAfterSetFont.java
41153 views
/*1* Copyright (c) 2012, 2016, 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* Portions Copyright (c) 2012 IBM Corporation25*/2627/*28@test29@key headful30@bug 717065531@summary Frame size does not change after changing font32@author Jonathan Lu33@library ../../regtesthelpers34@build Util35@run main ResizeAfterSetFont36*/3738import java.awt.*;39import test.java.awt.regtesthelpers.Util;4041public class ResizeAfterSetFont {4243public static void main(String[] args) throws Exception {44Frame frame = new Frame("bug7170655");45frame.setLayout(new BorderLayout());46frame.setBackground(Color.LIGHT_GRAY);4748Panel panel = new Panel();49panel.setLayout(new GridLayout(0, 1, 1, 1));5051Label label = new Label("Test Label");52label.setBackground(Color.white);53label.setForeground(Color.RED);54label.setFont(new Font("Dialog", Font.PLAIN, 12));5556panel.add(label);57frame.add(panel, "South");58frame.pack();59frame.setVisible(true);6061Util.waitForIdle(null);6263Dimension dimBefore = frame.getSize();64label.setFont(new Font("Dialog", Font.PLAIN, 24));6566frame.validate();67frame.pack();68Dimension dimAfter = frame.getSize();6970if (dimBefore.equals(dimAfter)) {71throw new Exception(72"Frame size does not change after Label.setFont()!");73}74}75}767778