Java Example Program / Sample Source Code
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Point;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
class MouseWheelListenerExample {
public static void main(String args[]) {
Frame frame = new Frame("MouseWheelListenerExample");
frame.pack();
frame.setSize(new Dimension(350, 250));
frame.setVisible(true);
frame.addMouseWheelListener(new MouseWheelListener() {
// invoked when mouse is moved over the panel
@Override
public void mouseWheelMoved(MouseWheelEvent me) {
Point point = me.getPoint();
System.out.println(point);
}
});
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
}
} |
|
|