List of usage examples for javax.swing JSlider addMouseWheelListener
public synchronized void addMouseWheelListener(MouseWheelListener l)
From source file:Main.java
/** * Creates a JSlider built//from w w w.j a va 2s .co m * using a {@link DefaultBoundedRangeModel} and * containing a {@link MouseWheelListener} * and some usual default settings * * @param model * @return the corresponding {@link JSlider} */ public static JSlider createJSlider(final BoundedRangeModel model) { final JSlider slider = new JSlider(model); slider.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { slider.setValue(-e.getWheelRotation() * model.getMaximum() / 100 + model.getValue()); } }); slider.setPaintTicks(true); slider.setPaintLabels(true); // slider.setMajorTickSpacing(model.getMaximum()/2); // slider.setMinorTickSpacing(model.getMaximum()/10); // slider.setSnapToTicks(true); return slider; }