How to draw a numbers onto a panel in a 2d array for a game board?
import javax.swing.*;
import java.awt.*;
public class board2 extends JFrame {
JFrame frame;
JPanel squares[][] = new JPanel[10][10];
public board2() {
setSize(500, 500);
setLayout(new GridLayout(10, 10));
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
squares[i][j] = new JPanel();
if ((i + j) % 2 == 0) {
squares[i][j].setBackground(Color.black);
} else {
squares[i][j].setBackground(Color.white);
}
add(squares[i][j]);
}
}
}
}
I would like to number the panels in the way shown here.