#1 MouseWheel in JEditTextArea

open
nobody
None
5
2001-11-15
2001-11-15
Peter Veentjer
No

MouseWheelSupport is missing, fix:

public
JEditTextAreaWithMouseWheel extends JEditTextArea implements
MouseWheelListener
{
private int mouseWheelUnit =
3;

public
JEditTextAreaWithMouseWheel()
{
super();

addMouseWheelListener(this);
}

public
JEditTextAreaWithMouseWheel(TextAreaDefaults
textAreaDefaults)
{
super(textAreaDefaults);

addMouseWheelListener(this);
}

public
int getMouseWheelUnit()
{
return
mouseWheelUnit;
}

public void setMouseWheelUnit(int
mouseWheelUnit)
{
this.mouseWheelUnit =
mouseWheelUnit;

}

public void
mouseWheelMoved(MouseWheelEvent
mouseWheelEvent)
{
if(mouseWheelEvent.getScrollAmount()
==
0)
return;

vertical.setValue(vertical.getValue()+mouseWheelUnit*mouseWheelEvent.getWheelRotation());
}
}

Discussion