title: Add image thumbnails to a layout in a grid?
body: <p>I have a list of images. I need to add as small thumbnails to a frame. I currently have frame with <code>SpringLayout</code>. How can add thumbnails in some grid like fashion with a scroll pane. The list of photos could be large, so I need a scroll pane. I don;t know how to handle this with <code>SpringLayout</code>. I know how to add thumbnails; the real question how can I show the grid of thumbnails in <code>SpringLayout</code>.</p>
  
  <pre><code>import java.awt.Color;
  import java.awt.Container;
  
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.SpringLayout;
  
  public class grid {
  
      /**
       * @param args
       */
      public grid() {
  
          JFrame frame = new JFrame("Hello");
          Container pane = frame.getContentPane();
  
          pane.setBackground(Color.WHITE);
          SpringLayout layout = new SpringLayout();
          pane.setLayout(layout);
  
          JPanel photoPanel = new JPanel();
          JScrollPane photoScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); 
          photoPanel.add(photoScroll);
          pane.add(photoPanel);
  
          layout.putConstraint(SpringLayout.WEST, photoPanel, 260, SpringLayout.WEST, pane);
          layout.putConstraint(SpringLayout.NORTH, photoPanel, 40, SpringLayout.SOUTH, pane);
  
          frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  
          frame.pack();
          //frame.setSize(frame.getMaximumSize());
          frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
          frame.setLocationRelativeTo(null);
          frame.setResizable(true);
          frame.setVisible(true);
      }
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
  
          new grid();
      }
  }
  </code></pre>