Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java
38828 views
/*1* Copyright (c) 2009, 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/*24test25@bug 500403226@summary GridBagConstraints.ipad(x|y) defined in a new way27@author [email protected] area=28@run applet GridBagLayoutIpadXYTest.html29*/3031import java.applet.Applet;32import java.awt.*;3334public class GridBagLayoutIpadXYTest extends Applet35{36Frame frame = new Frame();37TextField jtf = null;38final int customIpadx = 300;39final int customIpady = 40;4041public void init()42{43this.setLayout (new BorderLayout ());4445String[] instructions =46{47"This is an AUTOMATIC test",48"simply wait until it is done"49};50}//End init()5152public void start ()53{54validate();55frame.setLayout(new GridBagLayout());56GridBagConstraints gc = new GridBagConstraints();57Insets fieldInsets = new Insets(0,5,5,0);5859gc.anchor = gc.NORTH;60gc.fill = gc.HORIZONTAL;61gc.gridx = 1;62gc.gridy = 0;63gc.weightx = 1;64gc.ipadx = customIpadx;65gc.ipady = customIpady;66gc.insets = fieldInsets;67jtf = new TextField();68frame.add(jtf, gc);6970frame.pack();71frame.setVisible(true);7273Robot robot;74try {75robot = new Robot();76robot.waitForIdle();77}catch(Exception ex) {78ex.printStackTrace();79throw new RuntimeException("Unexpected failure");80}8182Dimension minSize = jtf.getMinimumSize();83if ( minSize.width + customIpadx != jtf.getSize().width ||84minSize.height + customIpady != jtf.getSize().height ){85System.out.println("TextField originally has min size = " + jtf.getMinimumSize());86System.out.println("TextField supplied with ipadx = 300, ipady =40");87System.out.println("Frame size: " + frame.getSize());88System.out.println(" Fields's size is "+jtf.getSize());8990throw new RuntimeException("Test Failed. TextField has incorrect width. ");91}92System.out.println("Test Passed.");9394}// start()95}969798