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.
public class board {
private static JFrame window;
private static JPanel[][] grid;
public static void main(String[] args) {
window = new JFrame();
window.setTitle("GAME BOARD");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
grid = new JPanel[10][10];
for (int i =0; i< 10; i++) {
for (int j =0; j< 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);
}
}
