Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Mixing/AWT_Mixing/JInternalFrameOverlapping.java
47626 views
/*1* Copyright (c) 2014, 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*/222324import java.awt.Point;25import java.awt.Robot;26import java.awt.event.MouseAdapter;27import java.awt.event.MouseEvent;28import javax.swing.JButton;29import javax.swing.JDesktopPane;30import javax.swing.JFrame;31import javax.swing.JInternalFrame;32import test.java.awt.regtesthelpers.Util;3334/**35* AWT/Swing overlapping test for {@link javax.swing.JInternalFrame } component.36* <p>See base class for test info.37*/38/*39@test40@summary Overlapping test for javax.swing.JScrollPane41@author [email protected]: area=awt.mixing42@library ../../regtesthelpers43@build Util44@run main JInternalFrameOverlapping45*/46public class JInternalFrameOverlapping extends OverlappingTestBase {4748private boolean lwClicked = true;49private Point lLoc;5051protected boolean performTest() {525354// run robot55Robot robot = Util.createRobot();56robot.setAutoDelay(ROBOT_DELAY);5758clickAndBlink(robot, lLoc);5960return lwClicked;61}6263/**64* Creating two JInternalFrames in JDesktopPanes. Put lightweight component into one frame and heavyweight into another.65*/66@Override67protected void prepareControls() {68JDesktopPane desktopPane = new JDesktopPane();6970JFrame frame = new JFrame("Test Window");71frame.setSize(300, 300);72frame.setContentPane(desktopPane);73frame.setVisible(true);74JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);75bottomFrame.setSize(220, 220);76desktopPane.add(bottomFrame);77bottomFrame.setVisible(true);7879super.propagateAWTControls(bottomFrame);80JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);81topFrame.setSize(200, 200);82JButton jbutton = new JButton("LW Button") {{83addMouseListener(new MouseAdapter() {8485@Override86public void mouseClicked(MouseEvent e) {87lwClicked = true;88}89});90}};91topFrame.add(jbutton);92desktopPane.add(topFrame);93topFrame.setVisible(true);94lLoc = jbutton.getLocationOnScreen();95lLoc.translate(jbutton.getWidth()/2, jbutton.getWidth()/2); //click at middle of the button96}9798// this strange plumbing stuff is required due to "Standard Test Machinery" in base class99public static void main(String args[]) throws InterruptedException {100instance = new JInternalFrameOverlapping();101OverlappingTestBase.doMain(args);102}103104}105106107