How can i display multiple Pictures in a java.awt.Container best?
hi,
I just started with a new Project, it works just like a FileManager.
On entering a directory all the files in it shall be displayed in a scrollable area. Displayed means here a Graphical representation of the file, in case of a picture a small preview version of it.
I put together a javax.swing.JScrollPane with a java.awt.Container and viewport. The Container has a FlowLayout.
Now for every image in a Directory I create a Component-class in witch I overwrote the public void paint(Graphics g) to display a scaled version of the image, this scaled version is created in the Constructor of my Component-class.
this works fine for just a few images, but if i try to open a directory with a lot of pictures it takes a long time at the beginning and sometimes it just kills the application.
so i changed in a way that only when a Component is in view of the visible rectangle of the scroll pane the scaled image will be created, and when the component gets out of view the image is set to null.
now it is running without killing the application, but it takes way too long to scroll now, because the images are loaded all the time.
so i figured i must be doing something wrong, so what is the best way to get small previews for up to a few hundred files and then display them in a scrollable area? (like in Windows Explorer if you activate the miniature preview)
if anyone can give me some hints, that would be great
thanks shirasuresh

