textArea.setAnimateBracketMatching(false);
textArea.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, new Color(248,248,248)));
textArea.getDocument().addDocumentListener(this);
final RTextScrollPane scroller = new RTextScrollPane(textArea);
scroller.setWheelScrollingEnabled(false);
gutter = scroller.getGutter();
scroller.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent event) {
if (event.isControlDown()) {
// Control + wheel: zoom.
if (event.getWheelRotation() > 0) {
decrementFontSize();
}
else {
incrementFontSize();
}
} else {
// scroll vertically.
JScrollBar bar;
if (event.isShiftDown()) {
// Shift + wheel: scroll horizontally.
bar = scroller.getHorizontalScrollBar();
} else {
// Wheel alone: scroll vertically.
bar = scroller.getVerticalScrollBar();
}
int newValue = bar.getValue() + bar.getBlockIncrement()
* event.getUnitsToScroll();
bar.setValue(newValue);
}