List of usage examples for java.awt.event MouseWheelEvent getUnitsToScroll
public int getUnitsToScroll()
From source file:Main.java
public void mouseWheelMoved(MouseWheelEvent e) { String message;/*from w ww . j ava 2 s .com*/ int notches = e.getWheelRotation(); if (notches < 0) { message = "Mouse wheel moved UP " + -notches + " notch(es)" + newline; } else { message = "Mouse wheel moved DOWN " + notches + " notch(es)" + newline; } if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { message += " Scroll type: WHEEL_UNIT_SCROLL" + newline; message += " Scroll amount: " + e.getScrollAmount() + " unit increments per notch" + newline; message += " Units to scroll: " + e.getUnitsToScroll() + " unit increments" + newline; message += " Vertical unit increment: " + scrollPane.getVerticalScrollBar().getUnitIncrement(1) + " pixels" + newline; } else { // scroll type == MouseWheelEvent.WHEEL_BLOCK_SCROLL message += " Scroll type: WHEEL_BLOCK_SCROLL" + newline; message += " Vertical block increment: " + scrollPane.getVerticalScrollBar().getBlockIncrement(1) + " pixels" + newline; } saySomething(message, e); }
From source file:MouseWheelEventDemo.java
public void mouseWheelMoved(MouseWheelEvent e) { String message;//from w w w .j a v a2 s. co m int notches = e.getWheelRotation(); if (notches < 0) { message = "Mouse wheel moved UP " + -notches + " notch(es)" + newline; } else { message = "Mouse wheel moved DOWN " + notches + " notch(es)" + newline; } if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { message += " Scroll type: WHEEL_UNIT_SCROLL" + newline; message += " Scroll amount: " + e.getScrollAmount() + " unit increments per notch" + newline; message += " Units to scroll: " + e.getUnitsToScroll() + " unit increments" + newline; message += " Vertical unit increment: " + scrollPane.getVerticalScrollBar().getUnitIncrement(1) + " pixels" + newline; } else { //scroll type == MouseWheelEvent.WHEEL_BLOCK_SCROLL message += " Scroll type: WHEEL_BLOCK_SCROLL" + newline; message += " Vertical block increment: " + scrollPane.getVerticalScrollBar().getBlockIncrement(1) + " pixels" + newline; } saySomething(message, e); }
From source file:events.MouseWheelEventDemo.java
public void mouseWheelMoved(MouseWheelEvent e) { String message;/*from w w w. j av a2s . co m*/ int notches = e.getWheelRotation(); if (notches < 0) { message = "Mouse wheel moved UP " + -notches + " notch(es)" + NEWLINE; } else { message = "Mouse wheel moved DOWN " + notches + " notch(es)" + NEWLINE; } if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { message += " Scroll type: WHEEL_UNIT_SCROLL" + NEWLINE; message += " Scroll amount: " + e.getScrollAmount() + " unit increments per notch" + NEWLINE; message += " Units to scroll: " + e.getUnitsToScroll() + " unit increments" + NEWLINE; message += " Vertical unit increment: " + scrollPane.getVerticalScrollBar().getUnitIncrement(1) + " pixels" + NEWLINE; } else { //scroll type == MouseWheelEvent.WHEEL_BLOCK_SCROLL message += " Scroll type: WHEEL_BLOCK_SCROLL" + NEWLINE; message += " Vertical block increment: " + scrollPane.getVerticalScrollBar().getBlockIncrement(1) + " pixels" + NEWLINE; } eventOutput(message, e); }
From source file:com.anrisoftware.prefdialog.miscswing.multichart.freechart.FreechartXYChart.java
private Object resolveObject() { this.p = new PropertyChangeSupport(this); this.mouseScrollListener = new MouseWheelListener() { @Override/* w w w . jav a 2 s . co m*/ public void mouseWheelMoved(MouseWheelEvent e) { if (model == null) { return; } if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int offset = model.getOffset(); setOffset(offset + e.getUnitsToScroll()); } } }; this.modelListener = new ChartModelListener() { @Override public void chartChanged(ChartModelEvent e) { updateChart(e); } }; return this; }
From source file:org.evors.rs.ui.sandpit.SandPitCanvas.java
public SandPitCanvas() { camera = new SandPitCamera(Vector2D.ZERO, Vector2D.ZERO, 50); grid = new Grid(camera); MouseAdapter mouseAdapter = new MouseAdapter() { private Vector2D prevCoord = Vector2D.NaN; @Override//from ww w. j a v a2 s . c o m public void mouseDragged(MouseEvent me) { Vector2D newCoord = getCamera().convertScreenToWorldCoords(new Vector2D(me.getX(), me.getY())); if (prevCoord == Vector2D.NaN) { prevCoord = newCoord; } else { Vector2D sub = newCoord.subtract(prevCoord); getCamera().move(sub); draw(); } } @Override public void mouseReleased(MouseEvent me) { prevCoord = Vector2D.NaN; } @Override public void mouseWheelMoved(MouseWheelEvent mwe) { getCamera().changeScale(-0.5 * mwe.getUnitsToScroll()); draw(); } }; addMouseListener(mouseAdapter); addMouseMotionListener(mouseAdapter); addMouseWheelListener(mouseAdapter); }