Duplicate :
|
|
Relates :
|
|
Relates :
|
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().
|