• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Problems with ImageIcon when focus is lost

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!

 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic