title: how do you use Grid layout in panels in Java?
body: <p>Im trying to create a JFrame with two panels. the top panel will contain a text field and the bottom panel will contain a grid of buttons. Ive used gridLayout to to arrange the buttons and added them into a panel and added the panel to the JFrame but according to the editor the value of panel is NULL. The same is true of the second panel. Could someone help direct me to the problem?</p>
  
  <pre><code>import java.awt.*;
  import javax.swing.*;
  
  public class frameClass extends JFrame{
      private static final long serialVersionUID = 1L;
  private JFrame frame;
  
  private JPanel panel;
  private JPanel panel2;
  
  private JButton button0;
  private JButton button1;
  private JButton button2;
  private JButton button3;
  
  public frameClass() {
      panel = new JPanel(new GridLayout(4,4,5,5));            
  
      panel.setBackground(Color.BLACK);
  
      Font font1 = new Font("SanSerif",Font.BOLD, 16);
  
      button0 = new JButton("0");
      button0.setFont(font1);
      button0.setBackground(Color.BLACK);
      button0.setForeground(Color.WHITE);
      panel.add(button0);
  
      button1 = new JButton("1");
      button1.setFont(font1);
      button1.setBackground(Color.WHITE);
      panel.add(button1);
  
      button2 = new JButton("2");
      button2.setFont(font1);
      button2.setBackground(Color.BLACK);
      button2.setForeground(Color.WHITE);
      panel.add(button2);
  
      button3 = new JButton("3");
      button3.setFont(font1);
      button3.setBackground(Color.WHITE);
      panel.add(button3);
  
              frame.add(panel);
              panel2 = new JPanel(new BorderLayout());
      panel2.add(new JTextField(21), BorderLayout.CENTER);
  
      frame.add(panel2);
      frame.setVisible(true);
  }
  public static void main(String[] args) {
      new calculator();       
  }
  }
  </code></pre>