1 /* 2 * Copyright (c) 2009, 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 6847958 27 @library ../../../regtesthelpers 28 @summary MouseWheel event is getting triggered for the disabled Textarea in jdk7 b60 pit build. 29 @author Dmitry Cherepanov: area=awt.event 30 @build Util 31 @run main DisabledComponent 32 */ 33 34 /** 35 * DisabledComponent.java 36 * 37 * summary: Tests that wheel events aren't coming on disabled component 38 */ 39 40 import java.awt.*; 41 import java.awt.event.*; 42 43 import sun.awt.SunToolkit; 44 45 import test.java.awt.regtesthelpers.Util; 46 47 public class DisabledComponent 48 { 49 50 private static volatile boolean passed = true; 51 52 public static void main(String []s) throws Exception 53 { 54 Frame frame = new Frame(); 55 frame.setBounds(100,100,400,400); 56 frame.setLayout(new FlowLayout()); 57 58 TextArea textArea = new TextArea("TextArea", 6, 15); 59 frame.add(textArea); 60 61 List list = new List(3); 62 list.add("1"); 63 list.add("2"); 64 list.add("3"); 65 frame.add(list); 66 67 MouseWheelListener listener = new MouseWheelListener(){ 68 @Override 69 public void mouseWheelMoved(MouseWheelEvent mwe){ 70 System.err.println(mwe); 71 passed = false; 72 } 73 }; 74 75 76 list.addMouseWheelListener(listener); 77 textArea.addMouseWheelListener(listener); 78 79 frame.setVisible(true); 80 ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); 81 82 Robot robot = new Robot(); 83 84 // point and wheel on the list 85 Util.pointOnComp(list, robot); 86 ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); 87 88 robot.mouseWheel(2); 89 ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); 90 91 // disable the text area 92 System.err.println(" disable text area "); 93 textArea.setEnabled(false); 94 passed = true; 95 96 // point and wheel on the text area 97 Util.pointOnComp(textArea, robot); 98 ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); 99 100 robot.mouseWheel(2); 101 ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); 102 103 if (!passed) { 104 throw new RuntimeException(" wrong wheel events "); 105 } 106 } 107 }