File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes Repainting of applets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Repainting of applets" Watch "Repainting of applets" New topic

Repainting of applets

N SRao

Joined: Nov 13, 2001
Posts: 11
I am running the applet which has menubar,toolbar with lot of images and where user can drag and drop the images on the panel provided in the applet itself. My problem is when ever i refresh the screen by clicking the refresh button on the browser the entire applet will be appear distorted with the toolbar, menubar, images and all the other panels in the applet will appear double and none of the events will be fired.
so kindly let me know what will be the solution
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

Invoking the browser's refresh probably repaints damaged or unprocessed regions of the browser space. Your applet's repaint() method should get called eventually, and the system will then "decide" which areas need repainting.
repaint() in the Applet class calls update(), which blanks the display area and draws a filled rectangle; this is followed by a call to paint() which does the rendering.
It may be the code you are using doesn't have the paint() method implemented with this is mind. Sometimes people will override the update() method to eliminate the screen wash, but forget to clear the screen some other way before redraw. Then you get what looks like a superimposition of two views on one space.
Take a second look at the paint() code with this in mind.
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
I agree. Here's the link:
subject: Repainting of applets
It's not a secret anymore!