0

I'm writing a little photo application and I ran into some problems. I asked a question about how I could create some kind of thumbnail overview yesterday and I have finally made some progress!

I've been able to display a picture using this code:

private ImageIcon thumbs;
private DefaultListModel listmodel;
...
public void loadIntoUpperSection(File folder) {
    listmodel.removeAllElements();
    File[] images = folder.listFiles(); 

    for (int j = 0; j < images.length; j++) {
        thumbs = new ImageIcon(images[j].toString());
        listmodel.addElement(thumbs);
    }
}

However, it looks like this:

https://i.stack.imgur.com/XxaDs.png

There were 17 pictures in the folder I chose but only one is visible and that one is way too big.

Where are the other pictures? is it because this one picture is too big? And how could I resize it? I've tried this but it doesn't seem to work. (I guess because of my JList's default renderer?)

Greetings

Community
  • 1
  • 1
ramy
  • 64
  • 1
  • 15
  • 2
    For better help sooner please provide a valid [mcve] or [sscce](http://sscce.org/) that we can copy-paste and see the issue. Include all the imports and a `main` method – Frakcool Jan 10 '17 at 02:01
  • 2
    `And how could I resize it? ` - well you have code you found in another question to test. So forget about your JList and solve one problem at a time. First create a JFrame with two labels. The first label will contain the Image at its actual size. The second label will contain the image at its scale size. Once you understand this basic concept, then you simply add the scaled ImageIcons to the JList and everything should work. Learn to simplify your problems when you ask a question. – camickr Jan 10 '17 at 02:57
  • Possible duplicate of [*Add image thumbnails to a layout in a grid?*](http://stackoverflow.com/q/15961412/230513) – trashgod Jan 10 '17 at 03:07

0 Answers0