Subclass won't use it's paint() Method

Hi there,

Ich am writing an Applet consisting of multiple .java Files.

My Main.java File (extends Applet) konstructs an objekt out of the Animation.java file/class (doesn’t extend anywere).

The animation constructor calls the constuctor of a subclass “Scale” (extends Canvas).

The Animation class has a method called refresh(). This calls another refresh() Method within the Scale-class. I put a System.out.println(“Hello World, my name is Scale.refresh()”); in there and that is displayed.
After refresh() (The one in scale) has done some calculations is calls repaint(). I put a System.out.println("…"); in the scale’s paint(Graphics g) method but this is never displayed in the console.

If I try to put an add(scale); (I called the objekt from Scale scale) in the Animation constructor Eclipse outputs the following error message:

The method add(Animation.Scale) is undefined for the type Animation      Animation.java

Why isn’t scale’s paint method called?
(Please feel free to just make suggestions if you don’t know a working answer because I need to get this finished today.)

Btw.: Extending Animation to Canvas and then adding the Animation-objekt in the Main class (that works) doesn’t solve my problem.

Calling repaint() schedules a repaint but doesn’t actually force the paint() call. Maybe its just the scheduled repaint hasn’t occured yet?

repaint(0); forces the paint() to happen within 0 milliseconds (?), i.e. straight away, maybe that’ll work better.

Kev

OK, thank’s I’ve fixed that problem.

But I’ve got a new one.

Another subclass of Animation in Rectangular. This is extended to PhysicsEngine which (currently is empty) is extended to canvas

Now the paint method of Rectangular is called and all Graphics methods work, but they dont’t draw their stuff on the screen.

Without code Im kind of stabbing in the dark.

Are you drawing to the Graphics object passed in to the paint() call?