Class that implements Runnable run() try – catch sleep() class MyThread implements Runnable { public MyThread(…..parameters…..){ ……..Initialize class variables…… } public void run() { for........ { Stuff…………. try { Thread.sleep(DELAY); } catch(InterruptedException e) {} }
Quick Thread Review cont…
Main class that creates your Runnable object public static void main (String args[]) { …..set your initial values….. MyThread thread = new MyThread(..parameters..); Thread t = new Thread(thread); Thread.start(t); }
The Animation Part
Animation = threads + GUIs. Basic Ideas for animation: paintComponent() this is where your GUIs will be. MyThread run() This is where you change your positions sleep() – necessary to be able to see the animation repaint()
Comments