Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Geeske Bakker   on Feb 15 In Java Category.

  
Question Answered By: Jonah Brown   on Feb 15

I'm kind of curious as to why you don't want to use the paint method. If your
intention is to only paint a certain object  at a certain time, then that
component should only be added to your pane when necessary. If it's not a
component, then why can't you have some kind of flag inside your class that
indicates when it should be drawn and when it should not be.

Creating a new graphics  object will not accomplish anything. You'll be drawing
graphics to nowhere. One thing I've done in the past is create a new
BufferedImage and got a Graphics object that references that. Using that I had
a double buffer that I could then flip to the displayed pane. But that's only
because I needed double buffering. Anyways, if I were you, I'd have the paint
method call  the drawgraphic method  when a flag is set and pass the Graphics
object.

Share: