0

I have to read 10000 or more images from a folder and display it in a Jpanel. At a time user can view 5 rows in the screen. When user scroll down I should load the other 5 rows in to the screen.

When user scroll down I want to unload those previous loaded images from memory and load it again when user scroll up.

How can I achieve this?

What is the best way to load image in to panel with high performance.

Without scrolling what could be the alternative way to display large number(more than 10000) images to Jpanel.

serenesat
  • 4,611
  • 10
  • 37
  • 53
Rama Krishna
  • 120
  • 8
  • [JViewport might help you out](http://docs.oracle.com/javase/6/docs/api/javax/swing/JViewport.html#addChangeListener%28javax.swing.event.ChangeListener) – Neeraj Jain Mar 24 '15 at 13:05
  • here i am looking about loading and unloading the images from memory – Rama Krishna Mar 24 '15 at 13:07
  • you can unload be simply resetting the JLable where you will attach the image , and for loading use the same logic for the 1st five , but the main issue is to get the event on scrolling , for which i have provided you the link – Neeraj Jain Mar 24 '15 at 13:10
  • possible duplicate of [o display an image](http://stackoverflow.com/questions/4530428/o-display-an-image) – Catalina Island Mar 24 '15 at 14:20

1 Answers1

0

A fast way to load images would be to create a seperate Thread to load images. This will prevent your window from freezing while the images are loading. And as for showing the images, you can add a 5 rows of JLabels to a JFrame and add a MouseWheelListener to the JFrame so that you can change the images when the user scrolls.

Cheers.

nom
  • 256
  • 3
  • 16