The Timer and TimerListener classes can be used to cause the Rectangle component to move at each timer event:
class TimerListener implements ActionListener { public void actionPerformed(ActionEvent event) { component.moveBy(1, 1); } }
The Timer and TimerListener classes can be used to cause the Rectangle component to move at each timer event:
class TimerListener implements ActionListener { public void actionPerformed(ActionEvent event) { component.moveBy(1, 1); } }