This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding a shape to a canvas  RSS feed

 
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!