Example #1
0
 @Override
 public void mousePressed(final MouseEvent e) {
   requestFocusInWindow();
   mouseX = e.getX();
   final double w = getWidth() - SLIDERW;
   final double r = max - min;
   final double x = (value - min) * w / r;
   if (mouseX < x || mouseX >= x + SLIDERW) value = (int) (mouseX * r / w + min);
   oldValue = value;
   repaint();
 }
Example #2
0
  @Override
  public void mouseDragged(final MouseEvent e) {
    final double prop = (max - min) * (mouseX - e.getX()) / (getWidth() - SLIDERW);

    final int old = value;
    value = Math.max(min, Math.min(max, (int) (oldValue - prop)));

    if (value != old) {
      if (dialog != null) dialog.action(null);
      for (final ActionListener al : listenerList.getListeners(ActionListener.class)) {
        al.actionPerformed(null);
      }
      repaint();
    }
  }
Example #3
0
 @Override
 public void mouseMoved(final MouseEvent e) {
   mouseX = e.getX();
 }