FULL PRODUCT VERSION :
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Versione 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
If you add a MouseWheelListener to a JFrame, and a MouseListener (or MouseMoveListener) to any of its children, and then run the application and move the mouse wheel over the frame (it is not necessary to move it while over the specific child) the window freezes for a while and then fires a StackOverflowError.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. extend a class from JFrame
2. in the constructor, use addMouseWheelListener to add whatever listener you like (even an empty one)
3. create a control of any kind (a JPanel, for example) and add it to the frame using add
4. use the addMouseListener to the created control to add a listener of any kind (once more, it works even with an empty one)
5. run the application and move the mouse wheel over the frame
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The application handles events the right way, executing the mouseWheelMoved implementation of the frame listener when you move the mouse wheel.
ACTUAL -
The mouseWheelMoved implementation of the frame listener is never called, the application goes in an infinite loop and after a while a StackOverflowError is fired.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
at java.awt.Container.getMouseEventTargetImpl(Unknown Source)
at java.awt.Container.getMouseEventTarget(Unknown Source)
at java.awt.Container.getMouseEventTarget(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchMouseWheelToAncestor(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchMouseWheelToAncestor(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchMouseWheelToAncestor(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchMouseWheelToAncestor(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
(the same sequence of calls again and again)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class TestFrame extends JFrame
{
public TestFrame()
{
initialize();
}
private void initialize()
{
this.setSize(200, 200);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.addMouseWheelListener(new MouseWheelListener() {
public void mouseWheelMoved(MouseWheelEvent e)
{
}
});
JPanel outputBox = new JPanel();
outputBox.addMouseListener(new MouseInputAdapter() {});
getContentPane().setLayout(new BorderLayout());
getContentPane().add(outputBox, BorderLayout.CENTER);
this.show();
}
public static void main(String[] args)
{
TestFrame tf = new TestFrame();
}
}
---------- END SOURCE ----------