Пример #1
0
 private void refreshDisplay() {
   Timer timer =
       new Timer(
           40,
           new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
               revalidate();
               repaint();
             }
           });
   timer.setRepeats(true);
   timer.setCoalesce(true);
   timer.start();
 }
    /** Creates a timer if one doesn't already exist, then starts the timer thread. */
    private void start(int interval) {
      previousDelay = interval;
      lastCall = 0;

      if (timer == null) {
        timer = new Timer(interval, this);
      } else {
        timer.setDelay(interval);
      }

      if (ADJUSTTIMER) {
        timer.setRepeats(false);
        timer.setCoalesce(false);
      }

      timer.start();
    }