public void actionPerformed(ActionEvent e) {
   if (isVisible()) {
     repaint();
   } else {
     animator.stop();
   }
 }