Problems with ImageIcon when focus is lost

I am interested in having an application to display some gif files where the user can select from a list the image to display. For that I am basically using ImageIcon. The application basically works fine but When I overlap other window or I scroll down (or up) and then go back to the applet the image is not conserved. In other words, if I select an image different than the firstone and open another window and go back, the applet will display the fist image loaded. For a "working" minimal appler you can go to http://shadow.eas.gatech.edu/~choyos/Minimal/

I downloaded your files and images and got it working okay. Run this as–is to see. You'll have to change the name of the class and also its name in your applet tag.

I think the trouble may have been in a combination of leaving jPanel5 in class scope, not properly adding/removing it in your event code and the JAppletstart method being called after it was hidden, ie, after stop. I changed it around so all you have to do is setIcon for each date (list) selection.

Also the readLine method in DataInputStream has been deprecated as of JDK 1.1. See api. This compiles and runs in j2se 1.4.2.

Carlos Hoyos
Greenhorn

Joined: Aug 02, 2004
Posts: 3

posted Aug 03, 2004 07:16:00

0

Hi Craig, Thanks a lot for the code now it is working exactly as it is supposed to. Thanks again!!