• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Display an image for a set time

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an application that should load an image to be set as an icon for a JLabel from JPEG files. The file names are numbers ie. (0.jpg, 1.jpg, ...) so that i can choose the files with a loop and use the loop index as the image name to be retrieved.
Depending on some user action the picture should be set visible for about 5 seconds, set invisible, unload the image, retrieve the next image and then depending on the user action, show it again for another couple of seconds. The way I am doing it it takes the image a long time to be shown. I thought by loading it before I would actually need it that it would speed things up, but thats not what happens. It takes a long time for the image to visible. I have a resource manager class responsible for creating the images from the jpegs. They also have to be resized so that may be why it is taking so long. Here's the resource class makeImage method.


The load and show picture methods are in another class that defines a picture panel



So if the user action is appropriate then the picture panel should be displayed and another one loaded up. I thought using the SwingUtlities would solve any thread issues. Is there some additional thread sequencing that I should do in order for the action to be faster? Thanks for the suggestions.

[ June 23, 2004: Message edited by: Chris Ramsey ]
[ June 23, 2004: Message edited by: Chris Ramsey ]
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This works fast on my computer. If it's still too slow for you I suggest you explore using the createCompatibleImage method in the GraphicsConfiguration class. I've read it can make a difference in rendering time.
 
Chris Ramsey
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Craig! Will try this approach.
 
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic