Path: blob/master/test/jdk/java/awt/Insets/CombinedTestApp1.java
41149 views
/*1* Copyright (c) 1998, 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@test25@key headful26@bug 406838627@summary Insets are incorrect for Frame w/MenuBar28@library ../regtesthelpers29@build Util30@author Andrei Dmitriev : area=awt.insets31@run main CombinedTestApp132*/3334import java.awt.*;35import java.awt.event.*;36import test.java.awt.regtesthelpers.Util;3738public class CombinedTestApp139{40public static void main(String[] args)41{42Frame frame = new Frame("A test");43frame.setSize (200,200);4445frame.setLayout(new FlowLayout());46MenuBar mbar = new MenuBar();47Menu file = new Menu("File");48mbar.add(file);4950MenuItem quit = new MenuItem("Quit", new MenuShortcut(KeyEvent.VK_Q));51quit.addActionListener(new ActionListener() {52public void actionPerformed(ActionEvent e) { System.exit(0);}53});54file.add(quit);5556frame.setMenuBar(mbar);57frame.add(new Button("One"));58frame.add(new Button("Two"));59frame.add(new Button("Three"));6061frame.pack();62frame.setVisible(true);63try {64Robot robot = new Robot();65Util.waitForIdle(robot);66} catch(AWTException e){67throw new RuntimeException("Test interrupted.", e);68}6970Insets frameInsets = frame.getInsets();71System.out.println(frameInsets);72if (frameInsets.bottom < 0 || frameInsets.top < 0 ||73frameInsets.right < 0 || frameInsets.left <0){74throw new RuntimeException("Failed. Frames' Insets are incorrect.");75}76System.out.println(" Test Passed. ");77}78}798081