1 /* 2 * Copyright (c) 2011, 2014, 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 /* 25 test 26 @bug 6200670 27 @summary MouseMoved events are triggered by Choice when mouse is moved outside the component, XToolkit 28 @library ../../regtesthelpers/ 29 @author andrei.dmitriev area=choice 30 @build Util 31 @run applet PopdownGeneratesMouseEvents.html 32 */ 33 34 import test.java.awt.regtesthelpers.Util; 35 36 import java.applet.Applet; 37 import java.awt.*; 38 import java.awt.event.*; 39 40 public class PopdownGeneratesMouseEvents extends Applet { 41 private volatile Robot robot; 42 private final Choice choice1 = new Choice(); 43 44 private volatile MouseMotionHandler mmh; 45 46 public void init() { 47 for (int i = 1; i < 10; i++) { 48 choice1.add("item-0" + i); 49 } 50 choice1.setForeground(Color.RED); 51 choice1.setBackground(Color.RED); 52 mmh = new MouseMotionHandler(); 53 choice1.addMouseMotionListener(mmh); 54 Button b1 = new Button("FirstButton"); 55 Button b2 = new Button("SecondButton"); 56 add(b1); 57 add(choice1); 58 add(b2); 59 setLayout (new FlowLayout()); 60 } 61 62 public void start() { 63 setSize(300, 200); 64 setVisible(true); 65 validate(); 66 String toolkit = Toolkit.getDefaultToolkit().getClass().getName(); 67 68 /* 69 * Choice should not generate MouseEvents outside of Choice 70 * Test for XAWT only. 71 */ 72 try{ 73 robot = new Robot(); 74 robot.setAutoWaitForIdle(true); 75 robot.setAutoDelay(50); 76 77 if (toolkit.equals("sun.awt.X11.XToolkit")) { 78 testMouseMoveOutside(); 79 } else { 80 System.out.println("This test is for XToolkit only. Now using " 81 + toolkit + ". Automatically passed."); 82 return; 83 } | 1 /* 2 * Copyright (c) 2011, 2018, 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 /* 25 @test 26 @key headful 27 @bug 6200670 28 @summary MouseMoved events are triggered by Choice when mouse is moved outside the component, XToolkit 29 @library ../../regtesthelpers/ 30 @build Util 31 @run main PopdownGeneratesMouseEvents 32 */ 33 34 import test.java.awt.regtesthelpers.Util; 35 36 import java.awt.*; 37 import java.awt.event.*; 38 39 public class PopdownGeneratesMouseEvents extends Frame { 40 private volatile Robot robot; 41 private final Choice choice1 = new Choice(); 42 43 private volatile MouseMotionHandler mmh; 44 45 public static void main(final String[] args) { 46 PopdownGeneratesMouseEvents app = new PopdownGeneratesMouseEvents(); 47 app.init(); 48 app.start(); 49 } 50 51 public void init() { 52 for (int i = 1; i < 10; i++) { 53 choice1.add("item-0" + i); 54 } 55 choice1.setForeground(Color.RED); 56 choice1.setBackground(Color.RED); 57 mmh = new MouseMotionHandler(); 58 choice1.addMouseMotionListener(mmh); 59 Button b1 = new Button("FirstButton"); 60 Button b2 = new Button("SecondButton"); 61 add(b1); 62 add(choice1); 63 add(b2); 64 setLayout (new FlowLayout()); 65 } 66 67 public void start() { 68 setSize(300, 200); 69 setLocationRelativeTo(null); 70 setVisible(true); 71 validate(); 72 String toolkit = Toolkit.getDefaultToolkit().getClass().getName(); 73 74 /* 75 * Choice should not generate MouseEvents outside of Choice 76 * Test for XAWT only. 77 */ 78 try{ 79 robot = new Robot(); 80 robot.setAutoWaitForIdle(true); 81 robot.setAutoDelay(50); 82 83 if (toolkit.equals("sun.awt.X11.XToolkit")) { 84 testMouseMoveOutside(); 85 } else { 86 System.out.println("This test is for XToolkit only. Now using " 87 + toolkit + ". Automatically passed."); 88 return; 89 } |