1 /* 2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * Portions Copyright (c) 2012 IBM Corporation 26 */ 27 28 /* 29 @test 30 @bug 7170655 31 @summary Frame size does not change after changing font 32 @author Jonathan Lu 33 @library ../../regtesthelpers 34 @build Util 35 @run main ResizeAfterSetFont 36 */ 37 38 import java.awt.*; 39 import test.java.awt.regtesthelpers.Util; 40 41 public class ResizeAfterSetFont { 42 43 public static void main(String[] args) throws Exception { 44 Frame frame = new Frame("bug7170655"); 45 frame.setLayout(new BorderLayout()); 46 frame.setBackground(Color.LIGHT_GRAY); 47 48 Panel panel = new Panel(); 49 panel.setLayout(new GridLayout(0, 1, 1, 1)); 50 51 Label label = new Label("Test Label"); 52 label.setBackground(Color.white); 53 label.setForeground(Color.RED); 54 label.setFont(new Font("Dialog", Font.PLAIN, 12)); 55 56 panel.add(label); 57 frame.add(panel, "South"); 58 frame.pack(); 59 frame.setVisible(true); 60 61 Util.waitForIdle(null); 62 63 Dimension dimBefore = frame.getSize(); 64 label.setFont(new Font("Dialog", Font.PLAIN, 24)); 65 66 frame.validate(); 67 frame.pack(); 68 Dimension dimAfter = frame.getSize(); 69 70 if (dimBefore.equals(dimAfter)) { 71 throw new Exception( 72 "Frame size does not change after Label.setFont()!"); 73 } 74 } 75 }