title: Dynamically resize images linked to JLabels in a GridLayout layoutmanager
body: <p><strong>Current implementation layout:</strong>
  <img src="https://i.stack.imgur.com/c0r6E.png" alt="implementation layout"></p>
  
  <p>((EDIT: added
  <strong>Code:</strong> ))</p>
  
  <pre><code>private JPanel panelCenter;
  private List&lt;BufferedImage&gt; listCreatedImages;
  public ChooseCircuitPanel(List&lt;BufferedImage&gt; listCreatedImages) {
          this.listCreatedImages = listCreatedImages;
          initiate();
  }
  private void initiate() {
          setLayout(new BorderLayout(50, 50));
          panelCenter = new JPanel();
          LayoutManager theLayout = new GridLayout(0, 3, 0, 0);
          panelCenter.setLayout(theLayout);
          panelCenter.setBorder(BorderFactory.createLineBorder(Color.BLACK));
          for (BufferedImage bufferedImage : listCreatedImages) {
              ImageIcon theImage = new ImageIcon(bufferedImage);
              JLabel lblForImage = new JLabel(theImage);
              lblForImage.setBorder(BorderFactory.createLineBorder(Color.BLACK));
              panelCenter.add(lblForImage);
          }
          this.add(panelCenter, BorderLayout.CENTER);
  }
  </code></pre>
  
  <p><strong>Situation:</strong></p>
  
  <p>We want to display a race circuit here. A circuit should be displayed by placing standards tiles next to each other. It should be possible to resize the window, and with that, the circuit tiles should also resize.</p>
  
  <p>((<strong>EDIT</strong>: bit more info: The race circuit data is stored on a server and the desktop application has to translate the data to a visual thing, by placing some standard tiles in the right order. ))</p>
  
  <p>((<strong>EDIT</strong>: we are not allowed to use any external library. It should be doable by <strong>only using Java Swing code</strong>.))</p>
  
  <p>I thought about placing the images in a JLabel and placing these JLabels in a panel with GridLayout as layout manager.</p>
  
  <p>Using a GridLayout - I thought - it should be rather easy to get to a solution:
  the components in the GridLayout (= JLabels) already scale and do exactly what I want.
  <strong>Now, it would only be a matter of finding a way to resize the images so they fill the JLabels</strong>.</p>
  
  <p>As you can see: right now, the images have a fixed size and don't scale at all.</p>
  
  <p>I browsed a bit and saw lots of solutions that boil down to using <strong>Graphics2D</strong> and <strong>super.paintComponent</strong>, etc.</p>
  
  <p><strong>But most of these solutions had nothing to do with a GridLayout.</strong>
  So conclusive question:
  <strong>Is there an easier solution aside from using Graphics2D, etc. knowing that I use a GridLayout?</strong></p>
  
  <p>If not, I will of course use Graphics2D, etc. but I'm now just exploring my options. :)</p>
  
  <p>((EDIT: <strong>SOLVED</strong> The tiles now neatly fit on each other. Don't mind the misalignments, that's our fault.))
  <img src="https://i.stack.imgur.com/S8VOa.png" alt="result"></p>