Groovy Documentation

com.wordpress.tipsforjava.swing
[Java] Class MouseWheelController

java.lang.Object
  com.wordpress.tipsforjava.swing.MouseWheelController
All Implemented Interfaces:
MouseWheelListener

public class MouseWheelController
extends Object

This class allows you to control the units scrolled for each mouse wheel rotation relative to the unit increment value of the scroll bar. Specifying a scroll amount of 1, is equivalent to clicking the unit scroll button of the scroll bar once.

Authors:
Rob Camick
Darryl Burke


Field Summary
private MouseWheelListener[] realListeners

private int scrollAmount

private JScrollPane scrollPane

 
Constructor Summary
MouseWheelController(JScrollPane scrollPane)

Convenience constructor to create the class with a scroll amount of 1.

MouseWheelController(JScrollPane scrollPane, int scrollAmount)

Create the class with the specified scroll amount.

 
Method Summary
private MouseWheelEvent createScrollAmountEvent(MouseWheelEvent e)

int getScrollAmount()

Get the scroll amount

void install()

Install this class as the default listener for MouseWheel events.

void mouseWheelMoved(MouseWheelEvent e)

Redispatch a MouseWheelEvent to the real MouseWheelListeners

void setScrollAmount(int scrollAmount)

Set the scroll amount.

void uninstall()

Remove the class as the default listener and reinstall the original listeners.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

realListeners

private MouseWheelListener[] realListeners


scrollAmount

private int scrollAmount


scrollPane

private JScrollPane scrollPane


 
Constructor Detail

MouseWheelController

public MouseWheelController(JScrollPane scrollPane)
Convenience constructor to create the class with a scroll amount of 1.
Parameters:
scrollPane - the scroll pane being used by the mouse wheel


MouseWheelController

public MouseWheelController(JScrollPane scrollPane, int scrollAmount)
Create the class with the specified scroll amount.
Parameters:
scrollAmount - the scroll amount to by used for this scroll pane
scrollPane - the scroll pane being used by the mouse wheel


 
Method Detail

createScrollAmountEvent

private MouseWheelEvent createScrollAmountEvent(MouseWheelEvent e)


getScrollAmount

public int getScrollAmount()
Get the scroll amount
returns:
the scroll amount.


install

public void install()
Install this class as the default listener for MouseWheel events.


mouseWheelMoved

public void mouseWheelMoved(MouseWheelEvent e)
Redispatch a MouseWheelEvent to the real MouseWheelListeners


setScrollAmount

public void setScrollAmount(int scrollAmount)
Set the scroll amount. Controls the amount the scrollpane will scroll for each mouse wheel rotation. The amount is relative to the unit increment value of the scrollbar being scrolled.
Parameters:
scrollAmount - an integer value. A value of zero will use the default scroll amount for your OS.


uninstall

public void uninstall()
Remove the class as the default listener and reinstall the original listeners.


 

Groovy Documentation