Link to home
Start Free TrialLog in
Avatar of mb2297
mb2297

asked on

How does an applet behave when reloaded?

Hello experts,

I already have an open question in this vein, but I wanted to ask something more general here to help my understanding of the issue.

My Applet is part of a drawing tool, and it loads in an image to be drawn on from a URL. The JPanel that the image sits in automatically resizes itself when an image is loaded in. The problem I'm having is when the Applet is reloaded with a different image. When this happens, there are a couple of problems:

1. The JPanel for the image remains the same size, essentially cropping a larger image.
2. Whatever items were drawn onto the first image remain when the Applet is reloaded with a different image.

So it looks like the Objects created in the first load remain after the reload. Why is this? Is there a way to stop it happening?

Thanks,
Matt.



Avatar of Mick Barry
Mick Barry
Flag of Australia image

1. if you weant the panel to resize when a new image is loaded you need to implement that reloading yourself.
2. again the painting isimplemented in your applet, so if the applet is reloaded you need to clear anything that you are already painting. This can be implemnted in the start() method as I mentioned in your other q. The start() method will get called whenever the applet is loaded.
ASKER CERTIFIED SOLUTION
Avatar of Tomas Helgi Johannsson
Tomas Helgi Johannsson
Flag of Iceland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mb2297
mb2297

ASKER

Thanks for the clear explanation Tomas. Those links were very useful.

Matt.