blob: ef9acbbd2dbd0a92013d1ee7fcc41af37b81f5fd [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright (c) 2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/*
25 test
26 @bug 6480024
27 @library ../../../regtesthelpers
28 @build Util Sysout AbstractTest
29 @summary stack overflow on mouse wheel rotation within Applet
30 @author Andrei Dmitriev: area=awt.event
31 @run applet InfiniteRecursion_3.html
32*/
33
34/**
35 * InfiniteRecursion_3.java
36 *
37 * summary: put a JButton into Applet.
38 * Add MouseWheelListener to Applet.
39 * Rotating a wheel over the JButton would result in stack overflow.
40 */
41
42import java.awt.*;
43import java.awt.event.*;
44import javax.swing.*;
45import test.java.awt.regtesthelpers.Util;
46import test.java.awt.regtesthelpers.AbstractTest;
47import test.java.awt.regtesthelpers.Sysout;
48import java.applet.Applet;
49
50public class InfiniteRecursion_3 extends Applet {
51 final static Robot robot = Util.createRobot();
52 final static int MOVE_COUNT = 5;
53 static int actualEvents = 0;
54
55 public void init()
56 {
57 setLayout (new BorderLayout ());
58 }//End init()
59
60 public void start ()
61 {
62 JButton jButton = new JButton();
63
64 this.setSize(200, 200);
65 this.addMouseWheelListener(new MouseWheelListener() {
66 public void mouseWheelMoved(MouseWheelEvent e)
67 {
68 System.out.println("Wheel moved on APPLET : "+e);
69 actualEvents++;
70 }
71 });
72
73 this.add(jButton);
74
75 this.setVisible(true);
76 this.validate();
77
78 Util.waitForIdle(robot);
79
80 Util.pointOnComp(jButton, robot);
81 Util.waitForIdle(robot);
82
83 for (int i = 0; i < MOVE_COUNT; i++){
84 robot.mouseWheel(1);
85 robot.delay(10);
86 }
87
88 for (int i = 0; i < MOVE_COUNT; i++){
89 robot.mouseWheel(-1);
90 robot.delay(10);
91 }
92
93 Util.waitForIdle(robot);
94 if (actualEvents != MOVE_COUNT * 2) {
95 AbstractTest.fail("Expected events count: "+ MOVE_COUNT+" Actual events count: "+ actualEvents);
96 }
97 }// start()
98}