-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
None
-
beta
-
x86
-
windows_nt
If ScrollPane has wheel scrolling disabled with setWheelScrollingDisabled(false), but then has a MouseWheelListener added to it, it will still scroll in response to the wheel mouse. The following code demonstrates this:
// test to make sure clients can install their own behavior on a ScrollPane
import java.awt.*;
import java.awt.event.*;
public class OverrideTest extends Frame {
public static void main(String args[]) {
OverrideTest frame = new OverrideTest();
frame.show();
}
public OverrideTest() {
super("OverrideTest");
setSize(300, 300);
Panel pnl = new Panel();
pnl.setLayout(new GridLayout(10, 10));
for (int i = 0; i < 100; i++) {
pnl.add(new Label("Label " + i));
}
ScrollPane sp = new ScrollPane();
sp.add(pnl);
sp.setWheelScrollingEnabled(false);
sp.addMouseWheelListener(new MWL());
add(sp);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
pack();
}
class MWL implements MouseWheelListener {
public void mouseWheelMoved(MouseWheelEvent e) {
System.out.println("mouse wheel received. should not scroll");
}
}
}
Commenting out the addMouseWheelListener() line makes the problem disappear.
brent.christian@eng 2000-09-19
// test to make sure clients can install their own behavior on a ScrollPane
import java.awt.*;
import java.awt.event.*;
public class OverrideTest extends Frame {
public static void main(String args[]) {
OverrideTest frame = new OverrideTest();
frame.show();
}
public OverrideTest() {
super("OverrideTest");
setSize(300, 300);
Panel pnl = new Panel();
pnl.setLayout(new GridLayout(10, 10));
for (int i = 0; i < 100; i++) {
pnl.add(new Label("Label " + i));
}
ScrollPane sp = new ScrollPane();
sp.add(pnl);
sp.setWheelScrollingEnabled(false);
sp.addMouseWheelListener(new MWL());
add(sp);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
pack();
}
class MWL implements MouseWheelListener {
public void mouseWheelMoved(MouseWheelEvent e) {
System.out.println("mouse wheel received. should not scroll");
}
}
}
Commenting out the addMouseWheelListener() line makes the problem disappear.
brent.christian@eng 2000-09-19
- relates to
-
JDK-4481179 ScrollPane scrolls with setWheelScrollingEnabled(false)
-
- Closed
-