50 likes | 158 Views
Animation. Albert Johnson Molly Richardson Andrew Kruth. Concepts. Threads Runnable interface sleep() GUIs repaint() paintComponent (). Quick Thread Review. Class that implements Runnable run() try – catch sleep() class MyThread implements Runnable {
E N D
Animation Albert Johnson Molly Richardson Andrew Kruth
Concepts • Threads • Runnable interface • sleep() • GUIs • repaint() • paintComponent()
Quick Thread Review • 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()