title: About using GridBagLayout in Java
body: <p>I'm learning how to use GridBagLayout. I created two buttons in a JFrame. I tried making it that one of them occupies one collumn (the default), and the other two collumns, thus being twice the size of the first one (I know I can acheive this using setPrefferredSize, but my intention is to learn how to use gridwidth and gridheight).</p>
  
  <p>What's the problem? Thanks</p>
  
  <pre><code>import java.awt.*;
  import javax.swing.*;
  
  public class Main extends JFrame {
  
      Main(){
  
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          setSize(500,500);
  
          JPanel panel1 = new JPanel(new GridBagLayout());
          JButton b1,b2;
          b1 = new JButton("button 1");
          b2 = new JButton("button 2");
  
          GridBagConstraints gbc = new GridBagConstraints();
  
          gbc.gridx = 1;
          gbc.gridwidth = 1;
          panel1.add(b1);
          gbc.gridx = 2;
          gbc.gridwidth = 2;
          panel1.add(b2);
  
          add(panel1);
  
          setVisible(true);
  
      }
  
      public static void main(String[]args){
  
          Main m = new Main();
  
      }
  
  }
  </code></pre>