GeeCON Prague 2014*
The moose likes Applets and the fly likes Problems with ImageIcon when focus is lost Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Applets
Bookmark "Problems with ImageIcon when focus is lost " Watch "Problems with ImageIcon when focus is lost " New topic
Author

Problems with ImageIcon when focus is lost

Carlos Hoyos
Greenhorn

Joined: Aug 02, 2004
Posts: 3
Hello All,

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 am also including the code.. Thanks a lot!!!

Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
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 JApplet start 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
Hi Craig, Thanks a lot for the code now it is working exactly as it is supposed to. Thanks again!!
 
GeeCON Prague 2014
 
subject: Problems with ImageIcon when focus is lost