/* * Controller.java * * Created on April 21, 2005, 3:30 PM */ /** * * @author levenick */ import java.awt.*; public class Controller extends Thread { private BallFrame theFrame; private Ball theBall; private boolean running=true; public boolean getRunning() {return running;} /** Creates a new instance of Controller */ public Controller(BallFrame theFrame) { this.theFrame = theFrame; theBall = new Ball(100, 100, 20, Color.red); } public void toggleRunning() { running = !running; } public void run() { for(;;) { if (running) step(); pause(); } } public void paint(Graphics g) { theBall.paint(g); } private void step() { theBall.step(); theFrame.repaint(); } private void pause() { try { Thread.sleep(50); } catch (Exception e) {} } }