JInternalFrameOverlapping.java revision 14851:980da45565c8
1/* 2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25import java.awt.Point; 26import java.awt.Robot; 27import java.awt.event.MouseAdapter; 28import java.awt.event.MouseEvent; 29import javax.swing.JButton; 30import javax.swing.JDesktopPane; 31import javax.swing.JFrame; 32import javax.swing.JInternalFrame; 33import test.java.awt.regtesthelpers.Util; 34 35/** 36 * AWT/Swing overlapping test for {@link javax.swing.JInternalFrame } component. 37 * <p>See base class for test info. 38 */ 39/* 40 * @test 41 * @key headful 42 * @summary Overlapping test for javax.swing.JScrollPane 43 * @author sergey.grinev@oracle.com: area=awt.mixing 44 * @library ../../regtesthelpers 45 * @modules java.desktop/sun.awt 46 * java.desktop/java.awt.peer 47 * @build Util 48 * @run main JInternalFrameOverlapping 49 */ 50public class JInternalFrameOverlapping extends OverlappingTestBase { 51 52 private boolean lwClicked = true; 53 private Point lLoc; 54 55 protected boolean performTest() { 56 57 58 // run robot 59 Robot robot = Util.createRobot(); 60 robot.setAutoDelay(ROBOT_DELAY); 61 62 clickAndBlink(robot, lLoc); 63 64 return lwClicked; 65 } 66 67 /** 68 * Creating two JInternalFrames in JDesktopPanes. Put lightweight component into one frame and heavyweight into another. 69 */ 70 @Override 71 protected void prepareControls() { 72 JDesktopPane desktopPane = new JDesktopPane(); 73 74 JFrame frame = new JFrame("Test Window"); 75 frame.setSize(300, 300); 76 frame.setContentPane(desktopPane); 77 frame.setVisible(true); 78 JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false); 79 bottomFrame.setSize(220, 220); 80 desktopPane.add(bottomFrame); 81 bottomFrame.setVisible(true); 82 83 super.propagateAWTControls(bottomFrame); 84 JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false); 85 topFrame.setSize(200, 200); 86 JButton jbutton = new JButton("LW Button") {{ 87 addMouseListener(new MouseAdapter() { 88 89 @Override 90 public void mouseClicked(MouseEvent e) { 91 lwClicked = true; 92 } 93 }); 94 }}; 95 topFrame.add(jbutton); 96 desktopPane.add(topFrame); 97 topFrame.setVisible(true); 98 lLoc = jbutton.getLocationOnScreen(); 99 lLoc.translate(jbutton.getWidth()/2, jbutton.getWidth()/2); //click at middle of the button 100 } 101 102 // this strange plumbing stuff is required due to "Standard Test Machinery" in base class 103 public static void main(String args[]) throws InterruptedException { 104 instance = new JInternalFrameOverlapping(); 105 OverlappingTestBase.doMain(args); 106 } 107 108} 109