Arend van der Kolk wrote:indeed, according to the book the inner class MyDrawP comes after the go() method, not within the go()method.. . . .[
That should make no difference. Inner classes declared outside methods are members of their surrounding class, and they are in scope throughout the whole class, even before where they are declared. In some other languages, e.g. C, you would have to declare something before it is used, but Java® can recognise member declarations backwards.
Don't use Thread#sleep() in Swing components. because it stops the display from responding. Remember everything has to be done on the one
Thread. Try a Swing
timer instead. What may be happening is that the time taken to repaint the GUI is longer than the time between the creation of the panel object and the thread going to sleep. So the display is never actually seen.