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