Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Insets/CombinedTestApp1.java
38813 views
/*1* Copyright (c) 1998, 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@test25@bug 406838626@summary Insets are incorrect for Frame w/MenuBar27@library ../regtesthelpers28@build Util29@author Andrei Dmitriev : area=awt.insets30@run main CombinedTestApp131*/3233import java.awt.*;34import java.awt.event.*;35import test.java.awt.regtesthelpers.Util;3637public class CombinedTestApp138{39public static void main(String[] args)40{41Frame frame = new Frame("A test");42frame.setSize (200,200);4344frame.setLayout(new FlowLayout());45MenuBar mbar = new MenuBar();46Menu file = new Menu("File");47mbar.add(file);4849MenuItem quit = new MenuItem("Quit", new MenuShortcut(KeyEvent.VK_Q));50quit.addActionListener(new ActionListener() {51public void actionPerformed(ActionEvent e) { System.exit(0);}52});53file.add(quit);5455frame.setMenuBar(mbar);56frame.add(new Button("One"));57frame.add(new Button("Two"));58frame.add(new Button("Three"));5960frame.pack();61frame.setVisible(true);62try {63Robot robot = new Robot();64Util.waitForIdle(robot);65} catch(AWTException e){66throw new RuntimeException("Test interrupted.", e);67}6869Insets frameInsets = frame.getInsets();70System.out.println(frameInsets);71if (frameInsets.bottom < 0 || frameInsets.top < 0 ||72frameInsets.right < 0 || frameInsets.left <0){73throw new RuntimeException("Failed. Frames' Insets are incorrect.");74}75System.out.println(" Test Passed. ");76}77}787980