title: swing panel resizable gap
body: <p>I'm using eclipse and windowsbuilder, for making java gui application. I'm having a trouble in maintaining the padding of the components in swing panel. I'm using the group layout in the windowbuilder designer to position components. But sadly I'm not able to maintain the the padding when the window gets re-sized. </p>
  
  <p><img src="https://i.stack.imgur.com/Ie4W3.png" alt="window on normal size">
  <br>Normal window</p>
  
  <p><img src="https://i.stack.imgur.com/3yvvJ.png" alt="Window on maximized">
  window when re-sized or maximized</p>
  
  <p>When the window is re-sized, I wish to make my app automatically re-size the horizontal and vertical gaps like in the third image so that component padding will be maintained correctly.
  <img src="https://i.stack.imgur.com/vRtkR.png" alt="Window padding i wish to have"></p>
  
  <p>The code:</p>
  
  <pre><code>public myframe() {
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setBounds(100, 100, 450, 300);
          contentPane = new JPanel();
          contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
          contentPane.setLayout(new BorderLayout(0, 0));
          setContentPane(contentPane);
  
          JPanel panel = new JPanel();
          contentPane.add(panel, BorderLayout.CENTER);
  
          JButton btnNewButton = new JButton("New button");
          GroupLayout gl_panel = new GroupLayout(panel);
          gl_panel.setHorizontalGroup(
              gl_panel.createParallelGroup(Alignment.TRAILING)
                  .addGroup(Alignment.LEADING, gl_panel.createSequentialGroup()
                      .addGap(166)
                      .addComponent(btnNewButton)
                      .addContainerGap(169, Short.MAX_VALUE))
          );
          gl_panel.setVerticalGroup(
              gl_panel.createParallelGroup(Alignment.LEADING)
                  .addGroup(gl_panel.createSequentialGroup()
                      .addGap(37)
                      .addComponent(btnNewButton)
                      .addContainerGap(192, Short.MAX_VALUE))
          );
          panel.setLayout(gl_panel);
      }
  </code></pre>