1400N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1400N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1400N/A *
1400N/A * This code is free software; you can redistribute it and/or modify it
1400N/A * under the terms of the GNU General Public License version 2 only, as
1400N/A * published by the Free Software Foundation.
1400N/A *
1400N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1400N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1400N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1400N/A * version 2 for more details (a copy is included in the LICENSE file that
1400N/A * accompanied this code).
1400N/A *
1400N/A * You should have received a copy of the GNU General Public License version
1400N/A * 2 along with this work; if not, write to the Free Software Foundation,
1400N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1400N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1400N/A */
1400N/A
1400N/A/*
1400N/A @test
1400N/A @bug 6847958
1400N/A @library ../../../regtesthelpers
1400N/A @summary MouseWheel event is getting triggered for the disabled Textarea in jdk7 b60 pit build.
1400N/A @author Dmitry Cherepanov: area=awt.event
1400N/A @build Util
1400N/A @run main DisabledComponent
1400N/A*/
1400N/A
1400N/A/**
1400N/A * DisabledComponent.java
1400N/A *
1400N/A * summary: Tests that wheel events aren't coming on disabled component
1400N/A */
1400N/A
1400N/Aimport java.awt.*;
1400N/Aimport java.awt.event.*;
1400N/A
1400N/Aimport sun.awt.SunToolkit;
1400N/A
1400N/Aimport test.java.awt.regtesthelpers.Util;
1400N/A
1400N/Apublic class DisabledComponent
1400N/A{
1400N/A
1400N/A private static volatile boolean passed = true;
1400N/A
1400N/A public static void main(String []s) throws Exception
1400N/A {
1400N/A Frame frame = new Frame();
1400N/A frame.setBounds(100,100,400,400);
1400N/A frame.setLayout(new FlowLayout());
1400N/A
1400N/A TextArea textArea = new TextArea("TextArea", 6, 15);
1400N/A frame.add(textArea);
1400N/A
1400N/A List list = new List(3);
1400N/A list.add("1");
1400N/A list.add("2");
1400N/A list.add("3");
1400N/A frame.add(list);
1400N/A
1400N/A MouseWheelListener listener = new MouseWheelListener(){
1400N/A @Override
1400N/A public void mouseWheelMoved(MouseWheelEvent mwe){
1400N/A System.err.println(mwe);
1400N/A passed = false;
1400N/A }
1400N/A };
1400N/A
1400N/A
1400N/A list.addMouseWheelListener(listener);
1400N/A textArea.addMouseWheelListener(listener);
1400N/A
1400N/A frame.setVisible(true);
1400N/A ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
1400N/A
1400N/A Robot robot = new Robot();
1400N/A
1400N/A // point and wheel on the list
1400N/A Util.pointOnComp(list, robot);
1400N/A ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
1400N/A
1400N/A robot.mouseWheel(2);
1400N/A ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
1400N/A
1400N/A // disable the text area
1400N/A System.err.println(" disable text area ");
1400N/A textArea.setEnabled(false);
1400N/A passed = true;
1400N/A
1400N/A // point and wheel on the text area
1400N/A Util.pointOnComp(textArea, robot);
1400N/A ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
1400N/A
1400N/A robot.mouseWheel(2);
1400N/A ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
1400N/A
1400N/A if (!passed) {
1400N/A throw new RuntimeException(" wrong wheel events ");
1400N/A }
1400N/A }
1400N/A}