Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems with ImageIcon when focus is lost

 
Carlos Hoyos
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Craig, Thanks a lot for the code now it is working exactly as it is supposed to. Thanks again!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic