Win a copy of Raising Young Coders: A Parent’s Guide to Teaching Programming at Home this week in the General Computing forum!
Forums Login/signup

Adding a shape to a canvas

+Pie Number of slices to send: Send
Hello everyone,
I've got a class that extends Thread and performs a simple animation by redrawing an oval every fraction of a second. What it actually does is that it sets the circle's color at the previous location to white and then recreates it with its normal color at the new position.
I have tried to add this to a canvas, or any other container for that matter, but to no avail. Note that I am not using the repaint() method.

I've defined a canvas in my main class (which extends Applet) as such:

I'm simply trying to add an object of type Graphics 'g' (from my other class) to the canvas. I've tried myCanvas.add(g), add(myCanvas); but doesn't seem to be working.

Any help would be greatly appreciated.
+Pie Number of slices to send: Send
I don't quite get your problem or your class structure.
Could you put up your entire class source code?

reply
reply
This thread has been viewed 860 times.
Similar Threads
Problem linking button to mouse event - Please help!
using constructors in gui programs
can constructors use 'extends'
problem in using paint
basic doubt in program
More...

All times above are in ranch (not your local) time.
The current ranch time is
Jun 27, 2025 09:02:59.