Path: blob/master/test/jdk/java/awt/Mixing/AWT_Mixing/JInternalFrameOverlapping.java
41152 views
/*1* Copyright (c) 2014, 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*/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* @key headful41* @summary Overlapping test for javax.swing.JScrollPane42* @author [email protected]: area=awt.mixing43* @library /java/awt/patchlib ../../regtesthelpers44* @modules java.desktop/sun.awt45* java.desktop/java.awt.peer46* @build java.desktop/java.awt.Helper47* @build Util48* @run main JInternalFrameOverlapping49*/50public class JInternalFrameOverlapping extends OverlappingTestBase {5152private boolean lwClicked = true;53private Point lLoc;5455protected boolean performTest() {565758// run robot59Robot robot = Util.createRobot();60robot.setAutoDelay(ROBOT_DELAY);6162clickAndBlink(robot, lLoc);6364return lwClicked;65}6667/**68* Creating two JInternalFrames in JDesktopPanes. Put lightweight component into one frame and heavyweight into another.69*/70@Override71protected void prepareControls() {72JDesktopPane desktopPane = new JDesktopPane();7374JFrame frame = new JFrame("Test Window");75frame.setSize(300, 300);76frame.setContentPane(desktopPane);77frame.setVisible(true);78JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);79bottomFrame.setSize(220, 220);80desktopPane.add(bottomFrame);81bottomFrame.setVisible(true);8283super.propagateAWTControls(bottomFrame);84JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);85topFrame.setSize(200, 200);86JButton jbutton = new JButton("LW Button") {{87addMouseListener(new MouseAdapter() {8889@Override90public void mouseClicked(MouseEvent e) {91lwClicked = true;92}93});94}};95topFrame.add(jbutton);96desktopPane.add(topFrame);97topFrame.setVisible(true);98lLoc = jbutton.getLocationOnScreen();99lLoc.translate(jbutton.getWidth()/2, jbutton.getWidth()/2); //click at middle of the button100}101102// this strange plumbing stuff is required due to "Standard Test Machinery" in base class103public static void main(String args[]) throws InterruptedException {104instance = new JInternalFrameOverlapping();105OverlappingTestBase.doMain(args);106}107108}109110111