I have this project for my programming class 1 for which I must play a board game, and I do not know how to make the board, I would like to help me how to do it using the pallete, thank you very much for answering me .
I have this project for my programming class 1 for which I must play a board game, and I do not know how to make the board, I would like to help me how to do it using the pallete, thank you very much for answering me .
Use a GridLayout (Grid distribution), and in each cell add a JPanel to which you can put a background color and border if you need to distinguish some cells from others.
Here is a bit of code:
///Define el tamaño de la cuadricula.
Nombre_De_Tu_Frame.setLayout(new GridLayout(6,6));
///for para agregar paneles.
for(int i=0;i<6*6;i++){
JPanel panel=new JPanel();
panel.setBackground(Color.red); ///se asigna un color.
Border borde;
borde = BorderFactory.createLineBorder(Color.black); ///se le pone un borde.
panel.setBorder(borde);
Nombre_De_Tu_Frame.add(panel); ///Se agrega el panel a la cuadricula una vez que tiene color y borde.
}