File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes problem in paint method. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problem in paint method." Watch "problem in paint method." New topic
Author

problem in paint method.

Ali Haider
Greenhorn

Joined: Feb 21, 2001
Posts: 25
I'm having problem when drawing on the applet. I'm using an image for drawing, means using image of the size of the applet for drawing. When I draw anything at the image, if I do the drawing in paint method then it works else not. Don't know whats the problem with it.
Reply soon
Thankx in advance
Kaspar Dahlqvist
Ranch Hand

Joined: Jun 18, 2001
Posts: 128
I was under the (perhaps incorrect) impression that painting only can be done in the paintmethod. So painting should only be done there. If you call a method during execution of the paintmethod and do some painting in that method, that will be fine, too!
/Kaspar
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

The reason you are having this problem is because of the repaint() -> update() -> paint() cycle that happens when the applet is repainted. The only thing that the applet 'remembers' to paint when the screen is refreshed is code in these methods, or code in methods called by these... a good rule of thumb is to keep all your painting code in the paint() method, or methods that are called by the paint method... anything else ( such as painting done in event handlers ) disappears when the screen is refreshed.

HTH,
-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in paint method.