title: How to resize a JFrame so that the components also expand or reduce in size, depending on user?
body: <p>I will explain my point using the pictures below:</p>
  
  <p>this example the project is executed:</p>
  
  <p><a href="https://i.stack.imgur.com/s1nLH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s1nLH.png" alt="http://i.stack.imgur.com/s1nLH.png"></a></p>
  
  <p>As you see the user re size's the frame, which then does not expand the components itself but instead fills it with a grey color:</p>
  
  <p><a href="https://i.stack.imgur.com/kdNA3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kdNA3.png" alt="http://i.stack.imgur.com/kdNA3.png"></a></p>
  
  <p>I would like to know how to re size the JFrame making the components within
     the frame expand or reduce in size depending on the user.</p>
  
  <p>Here is the main class of this program, I am using GridBag layout and before someone points out I do understand the setSize function can be overridden by the managers, Only realized after coding this program.</p>
  
  <p>Please note this is in fact for a project and this is just another previous program I have used, I would just like to know how to go about it.</p>
  
  <pre><code>public class Email{
  
      public static void main(String[] args) {
          // The GUI thread is created, with the JFrame in the run method
          SwingUtilities.invokeLater(new Runnable(){
  
               public void run(){
  
                  JFrame frame = new Compose("Send an Email");
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  frame.setSize(700 , 600);
                  // This stops the program from being resized
                  frame.setResizable(true);
                  frame.pack();
                  frame.setVisible(true);
              }
          });
      }
  
  }
  </code></pre>