Display images inside a JList?

回眸只為那壹抹淺笑 提交于 2019-12-25 18:04:07

问题


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...).

来源:https://stackoverflow.com/questions/41539517/display-images-inside-a-jlist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!