Display images inside a JList?

345 Views Asked by At

I have to write a little photo application for my studies and I have a problem: Basically I divided a frame into two sections: the upper section should display all of the images inside a folder in some kind of overview (thumbnails). If you select a thumbnail, the lower section of the frame should display the image in full size.

I'm not sure how to do the upper part right. I guess the best way to do it would be a JList with a horizontal LayoutOrientation?

I tried something like this:

public void loadIntoUpperSection(File directory){
   listmodel.removeAllElements();
   File[] images = directory.listFiles();
   for(int i=0; i<images.length; i++)
      listmodel.addElement(images[i]);
   }}

Now I should have all the paths to the images in my JList model, right? How would I display them? I read a lot of similar code but all of them include ImageIO and I'm not allowed to use it unfortunately (yeah...).

0

There are 0 best solutions below