-
Bug
-
Resolution: Won't Fix
-
P5
-
None
-
1.4.0, 1.4.2, 5.0, 6
-
generic, x86
-
linux_sun, windows_nt, windows_2000, windows_xp
I'm not sure if this is even a bug, but it is behavior that differs from Swing.
When MouseWheelListeners are added to several Components of a containment hierarchy, MouseWheelEvents are delivered to listeners all the way up the hierarchy. This differes from Swing, wherein only the top-most listener receives the event. Try the following test case:
// Test for problem 6 of 4475240
import java.awt.*;
import java.awt.event.*;
public class AWTTest6 implements MouseWheelListener {
public AWTTest6() {}
public static void main(String[] args) {
Frame f = new Frame();
Panel pnl = new Panel();
Button btn = new Button("Button");
pnl.setBackground(Color.RED);
f.addMouseWheelListener(new AWTTest6());
pnl.addMouseWheelListener(new AWTTest6());
btn.addMouseWheelListener(new AWTTest6());
pnl.add(btn);
f.add(pnl);
f.setSize(400, 400);
f.setVisible(true);
}
public void mouseWheelMoved(MouseWheelEvent e) {
System.out.println("mouseWheelMoved on " + e.getComponent().getName());
//e.consume();
}
}
The behavior can be worked-around by using MouseWheelEvent.consume().
When MouseWheelListeners are added to several Components of a containment hierarchy, MouseWheelEvents are delivered to listeners all the way up the hierarchy. This differes from Swing, wherein only the top-most listener receives the event. Try the following test case:
// Test for problem 6 of 4475240
import java.awt.*;
import java.awt.event.*;
public class AWTTest6 implements MouseWheelListener {
public AWTTest6() {}
public static void main(String[] args) {
Frame f = new Frame();
Panel pnl = new Panel();
Button btn = new Button("Button");
pnl.setBackground(Color.RED);
f.addMouseWheelListener(new AWTTest6());
pnl.addMouseWheelListener(new AWTTest6());
btn.addMouseWheelListener(new AWTTest6());
pnl.add(btn);
f.add(pnl);
f.setSize(400, 400);
f.setVisible(true);
}
public void mouseWheelMoved(MouseWheelEvent e) {
System.out.println("mouseWheelMoved on " + e.getComponent().getName());
//e.consume();
}
}
The behavior can be worked-around by using MouseWheelEvent.consume().
- duplicates
-
JDK-4786832 ScrollbarMouseWheelTest.html Failing on Win
-
- Closed
-
- relates to
-
JDK-6480024 Stack overflow on mouse wheel moved
-
- Resolved
-
-
JDK-6541448 java/awt/Scrollbar/ScrollbarMouseWheelTest/ScrollbarMouseWheelTest.html fails on Windows
-
- Closed
-