Example usage for java.awt.event MouseWheelEvent WHEEL_BLOCK_SCROLL

List of usage examples for java.awt.event MouseWheelEvent WHEEL_BLOCK_SCROLL

Introduction

In this page you can find the example usage for java.awt.event MouseWheelEvent WHEEL_BLOCK_SCROLL.

Prototype

int WHEEL_BLOCK_SCROLL

To view the source code for java.awt.event MouseWheelEvent WHEEL_BLOCK_SCROLL.

Click Source Link

Document

Constant representing scrolling by a "block" (like scrolling with page-up, page-down keys)

Usage

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(200, 200);/*  w  w  w.j a va2  s . c  o m*/
    JTextArea textArea = new JTextArea();
    textArea.addMouseWheelListener(new MouseWheelListener() {
        public void mouseWheelMoved(MouseWheelEvent e) {
            if (e.getWheelRotation() < 0) {
                System.out.println("Up... " + e.getWheelRotation());
            } else {
                System.out.println("Down... " + e.getWheelRotation());
            }
            System.out.println("ScrollAmount: " + e.getScrollAmount());

            if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
                System.out.println("MouseWheelEvent.WHEEL_UNIT_SCROLL");
            }

            if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
                System.out.println("MouseWheelEvent.WHEEL_BLOCK_SCROLL");
            }
        }
    });

    getContentPane().add(textArea);
}