|
Description
|
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
Adding a MouseWheelListener to JFrame or ScrollPane not work.
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame {
public Test() {
setBounds(100, 100, 600, 400);
setTitle("Prueba del MouseWheel");
addMouseWheelListener(new MouseWheelListener() {
public void mouseWheelMoved(MouseWheelEvent mwe) {
System.out.println("ScrollAmount: " + mwe.getScrollAmount());
System.out.println("ScrollType: " + mwe.getScrollType());
System.out.println("UnitsToScroll: " + mwe.getUnitsToScroll());
System.out.println("WheelRotation: " + mwe.getWheelRotation());
}
});
show();
}
public static void main (String args[]) {
new Test();
}
}
(Review ID: 127450)
======================================================================
|
|
Evaluation
|
Reproducible as of b70. Commit to merlin.
xxxxx@xxxxx 2001-06-28
There are a number of problems with the dispatching of MouseWheelEvents on Win32 (none are reproducible on Linux):
1. An empty Frame w/ a MouseWheelListener will never receive MouseWheelEvents.
2. Same for JFrame.
3. A Frame (w/ MWL) containing only a ScrollPane (w/ MWL) will never receive MWEs (neither will the ScrollPane).
(A JFrame (w/ MWL) containing only a JScrollPane (w/ MWL) behaves correctly.)
4. A Frame (w/ MWL) containing only a Panel (also w/ MWL) will not receive MouseWheelEvents when the Frame is shown, but BOTH Components receive MWEs once the Frame has been clicked on (only the "top" listener should receive the events).
5. A JFrame (m/ WWL) containing only a JPanel (w/ MWL) will never receive MWEs.
6. For a Frame (w/ MWL) containing a Panel (w/ MWL) containing a Button (w/ MWL), MWEs are delivered to all MWLs, even if the Frame is never clicked.
(A JFrame containing a JPanel containing a JButton, all MWLs, behaves correctly.)
7. For a Frame containing a ScrollPane containing a Button, MWLs receive MWEs even if the Frame is never clicked. MWEs are not dispatched above the ScrollPane.
(A JFrame containing a JScrollPane containing a JButton, all MWLs, behaves correctly.)
xxxxx@xxxxx 2001-08-09
Problems 1, 2, 3, and 5 are no longer reproducible in beta3 (as of b80, to be exact).
4, 6, and 7 are all similar: MouseWheelEvents are being propagated too far up the Containment hierarchy for AWT Components, but not Swing. This is probably the least serious part of this bug, as it can be easily worked around with MouseWheelEvent.consume(). I've filed a new bug for this problem, 4616935. I'm closing out this bug, as the problem in the original description is now fixed.
xxxxx@xxxxx 2001-12-20
Oh, I'm also attaching all of my test cases.
xxxxx@xxxxx 2001-12-20
|