Example #1
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 #2
0
 @Override
 public void keyPressed(final KeyEvent e) {
   final int old = value;
   if (PREVCHAR.is(e) || PREVLINE.is(e)) {
     value = Math.max(min, value - 1);
   } else if (NEXTCHAR.is(e) || NEXTLINE.is(e)) {
     value = Math.min(max, value + 1);
   } else if (NEXTPAGE.is(e)) {
     value = Math.max(min, value + 10);
   } else if (PREVPAGE.is(e)) {
     value = Math.min(max, value - 10);
   } else if (LINESTART.is(e)) {
     value = min;
   } else if (LINEEND.is(e)) {
     value = max;
   }
   if (value != old) {
     if (dialog != null) dialog.action(null);
     for (final ActionListener al : listenerList.getListeners(ActionListener.class)) {
       al.actionPerformed(null);
     }
     repaint();
   }
 }