getWheelRotation
Hello,
I'm having a bit of a trouble with the MouseWheelEvent's getWheelRotation() function;
As I read in the javadocs; Returns the number of "clicks" the mouse wheel was rotated.
But the MouseWheelListener's function mouseWheelMoved(MouseWheelEvent e) is being called every time the mousewheel has moved, so I getWheelRotation always returns 1 (or -1).
But it's very important for me to make sure that I get the total amount of clicks that the user has made with the mousewheel!
How would I achieve this?
Many thanks for any help!
Steven
[593 byte] By [
dekoffiea] at [2007-10-2 10:18:25]

On Fedora Core 3 Linux using JDK1.5.0_06 the following shows WheelRotation values greater than 1.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Fred20 extends JPanel
{
public Fred20()
{
super(new BorderLayout());
setPreferredSize(new Dimension(640,480));
addMouseWheelListener(new MouseWheelListener()
{
public void mouseWheelMoved(MouseWheelEvent e)
{
cumulativeWheelRotation += e.getWheelRotation();
System.out.println(e.getWheelRotation() + " " + cumulativeWheelRotation);
}
});
}
private int cumulativeWheelRotation = 0;
public static void main(String[] args)
{
JFrame frame = new JFrame("Mouse Wheel Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(new Fred20());
frame.pack();
frame.setVisible(true);
}
}