title: Java- JPanel design problems
body: <p><strong>UPDATE:</strong> NVM IM AN IDIOT PASSING A NULL
  <br><br>ummm so I recently learned about panels and I'm trying to redesign the start menu of a tictactoe project, nothing major. 
  <br><br>This is my dream: </p>
  
  <p><a href="https://i.stack.imgur.com/eyjKH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eyjKH.jpg" alt="enter image description here"></a></p>
  
  <p>This is my current code:</p>
  
  <pre><code>public static void modeGUI () {
  
      //MAIN JFRAME GUI
      JFrame gui = new JFrame("TicTacToe");
      gui.setVisible(true);
      gui.setSize(600, 200);
      gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
      //MAIN PANEL
      JPanel mainPanel = new JPanel();
      mainPanel.setLayout(new GridLayout(3, 1));
      gui.add(mainPanel);
  
      //QUESTION PANEL
      JPanel questionPanel = new JPanel();
      questionPanel.setLayout(new FlowLayout());
      JLabel q1 = new JLabel("Please select your mode");
      q1.setFont(new Font("Times New Roman", Font.PLAIN, 20));
      questionPanel.add(q1);
      mainPanel.add(questionPanel);
  
      //MODE PANEL
      JPanel  modePanel = new JPanel();
      modePanel.setLayout(new GridLayout());
      JButton[] modeButtons = new JButton[3];
      modeButtons[0].setText("First turn");
      modeButtons[1].setText("Second turn");
      modeButtons[2].setText("P vs. P");
      for (JButton modeButton : modeButtons) {
          modeButton.setFont(new Font("Times New Roman", Font.PLAIN, 20));
          modeButton.addActionListener(new Response());
          modePanel.add(modeButton);
      }
      mainPanel.add(modePanel);
  
      //OPTION PANEL
      JPanel optionsPanel = new JPanel();
      optionsPanel.setLayout(new FlowLayout());
      mainPanel.add(optionsPanel);
  }
  </code></pre>
  
  <p>However when I attempt to run it it gives an error at line 30, which correlates to this line: <code>modeButtons[0].setText("First turn");</code>. Can anyone help see what's wrong?</p>
  
  <p>This is the error btw: </p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NullPointerException     at
    Ttt.modeGUI(Ttt.java:30)  at Ttt.main(Ttt.java:7)</p>
  </blockquote>