This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding a shape to a canvas

 
Malcolm Whitely
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
saager mhatre
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't quite get your problem or your class structure.
Could you put up your entire class source code?
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!