Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Mixing/AWT_Mixing/JInternalFrameMoveOverlapping.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*/2223import java.awt.Point;24import java.awt.Robot;25import java.awt.event.InputEvent;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 during move.36* <p>See <a href="http://monaco.sfbay.sun.com/detail.jsf?cr=6985399">CR6768230</a> for details and base class for test info.37*/38/*39@test40@bug 698539941@summary Overlapping test for javax.swing.JScrollPane42@author [email protected]: area=awt.mixing43@library ../../regtesthelpers44@build Util45@run main JInternalFrameMoveOverlapping46*/47public class JInternalFrameMoveOverlapping extends OverlappingTestBase {4849private boolean lwClicked = true;50private Point locTopFrame;51private Point locTarget;5253protected boolean performTest() {54// run robot55Robot robot = Util.createRobot();56robot.setAutoDelay(ROBOT_DELAY);5758robot.mouseMove(locTopFrame.x + 25, locTopFrame.y + 25);59robot.mousePress(InputEvent.BUTTON1_MASK);60try {61Thread.sleep(500);62} catch (InterruptedException ex) {63}64robot.mouseMove(locTopFrame.x + (locTarget.x - locTopFrame.x)/2, locTopFrame.y + (locTarget.y - locTopFrame.y)/2);65try {66Thread.sleep(500);67} catch (InterruptedException ex) {68}69robot.mouseMove(locTarget.x, locTarget.y);70try {71Thread.sleep(500);72} catch (InterruptedException ex) {73}74robot.mouseRelease(InputEvent.BUTTON1_MASK);7576clickAndBlink(robot, locTarget);7778return lwClicked;79}8081//static {debugClassName = "Choice";}8283@Override84protected void prepareControls() {858687JDesktopPane desktopPane = new JDesktopPane();8889JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);90bottomFrame.setSize(220, 220);91super.propagateAWTControls(bottomFrame);92desktopPane.add(bottomFrame);93bottomFrame.setVisible(true);9495JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);96topFrame.setSize(200, 200);97topFrame.add(new JButton("LW Button") {9899{100addMouseListener(new MouseAdapter() {101102@Override103public void mouseClicked(MouseEvent e) {104lwClicked = true;105}106});107}108});109desktopPane.add(topFrame);110topFrame.setVisible(true);111112JFrame frame = new JFrame("Test Window");113frame.setSize(300, 300);114frame.setContentPane(desktopPane);115frame.setVisible(true);116117locTopFrame = topFrame.getLocationOnScreen();118locTarget = new Point(locTopFrame.x + bottomFrame.getWidth() / 2, locTopFrame.y + bottomFrame.getHeight()/2);119}120121// this strange plumbing stuff is required due to "Standard Test Machinery" in base class122public static void main(String args[]) throws InterruptedException {123instance = new JInternalFrameMoveOverlapping();124OverlappingTestBase.doMain(args);125}126}127128129