The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

update() method is the key

Posted by Kishori Sharan on July 14, 2001 at 12:43 PM

Hi
The behaviour of frame drawings you are getting is because of the way you have written your update ( Graphics g ) method for Line class. For all heavyweight components the default role of update method is to erase the background first and then call paint method. In your Line class you have overriden the update() method and hence the background that contains your previous drawings are not erased. I am not saying that you have done something wrong. I am just explaining thefact that why are you getting such behaviour. Therefore, if you call super method from update then you don't need to call paint from update and then you will see only one line.
public void update(Graphics g) {
super.update ( g ) ;
System.out.println("update " );
//paint(g); // No need to call this now. super.update will call paint method
}
Or, just take out update() method from your Line class .
Thanks
Kishori



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us