title: Added panel not showing up in frame (Java)
body: <p>I'm working on making a battleship game board using swing in java. I've added the panel (i.e. the grid or the game board) to the window but it still won't show up. I've pasted the code below. Any help is appreciated. Thanks.</p>
  <pre><code>public class board {
  
  private static JFrame window;
  private static JPanel[][] grid;
  
  public static void main(String[] args) {
      window = new JFrame();
      window.setTitle(&quot;GAME BOARD&quot;);
      window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      
      grid = new JPanel[10][10];
      for (int i =0; i&lt; 10; i++) {
          for (int j =0; j&lt; 10; j++) {
              grid[i][j] = new JPanel();
              grid[i][j].setBackground(Color.white);
              grid[i][j].setBorder(BorderFactory.createLineBorder(Color.black));
              grid[i][j].setPreferredSize(new Dimension(25,25));
              window.add(grid[i][j]);
          }
      }
      window.pack();
      window.setVisible(true);
  }
  </code></pre>
  <p>}</p>