// @topic T11738 2D Graphics demo 03 -- mouse events added // @brief class <tt>ThreadPainter</tt> implements <tt>Runnable</tt> package shopsimulation; public class ThreadPainter implements Runnable { public static final int SLEEP_TIMEOUT = 1000 / 24; // 24 fps ViewDesigner mWindow; // constructors public ThreadPainter( ViewDesigner window ) { mWindow = window; } @Override public void run() { for(;;) { // forever... try { // ask EDT thread to repaint itself java.awt.EventQueue.invokeLater(new Runnable() { public void run() { mWindow.getCanvas().repaint(); } }); // go to sleep for a period of time Thread.sleep(SLEEP_TIMEOUT); } catch (InterruptedException ie) { } } } }//class ThreadPainter