wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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!!
 
Don't get me started about those stupid light bulbs.
 
subject: Problems with ImageIcon when focus is lost
 
Similar Threads
Game GUI
JTabbedPane
Moving a picture down a bit
How to resize an application to screen size?
invalid use of "this" selector syntax