title: JPanel inside JPanel in JAVA
body: <pre><code>  public static void main(String[] args) {
        JTextField text = new JTextField();
        JFrame frame = new JFrame();
        frame.setLayout(new BorderLayout());      
        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(5, 4));
        JPanel panel2 = new JPanel();
        panel2.setLayout(new FlowLayout());
  
  
  
        JLabel imgLabel1 = new JLabel(new ImageIcon("C:\\Users\\Arthur\\Downloads\\abs.jpg"));
        JLabel imgLabel2 = new JLabel(new ImageIcon("C:\\Users\\Arthur\\Downloads\\abss.jpg"));
  
  
        imgLabel1.setPreferredSize(new Dimension(100,100));
        imgLabel2.setPreferredSize(new Dimension(100,100));
  
        panel2.add(imgLabel1);
        panel2.add(imgLabel2);
  
  
        for(int i=0; i&lt;20; i++){
            panel.add(panel2);
        }
  
  
        frame.add(text, BorderLayout.NORTH);
        frame.add(panel, BorderLayout.CENTER);      
        frame.setPreferredSize(new Dimension(1280,700));
        frame.pack();
        frame.setVisible(true);      
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      }
  </code></pre>
  
  <p>I want to make a memory game, I need to put two images in each cell of the JPanel of 4x5. For this I created a JPanel 1x2 with two images inside and put it in the JPanel of 4x5. But the result is:</p>
  
  <p><strong>Result:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/tZNzY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tZNzY.png" alt="enter image description here"></a></p>