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