Hello everyone and thanks in advance.
I'm trying to do a very basic looking mines, but first I have to draw the "board" and I'm a bit stuck with that. I'm doing it with Java swing. With a Jframe and inside two Jpanel, one in which I enter the rows and columns that will have the board and a button that calls a method that draws the buttons automatically, but I can not get me to draw the buttons, because I have tried that the code creates the buttons and creates them, but next to the method, it does not create them. I attach code fragment of the method to see if you can lend me a hand.
public void ponbotones(int filas, int columnas){
int pintar = 0;
for(int i=0; i<filas; i++){
JButton boton = new JButton(i+"");
boton.setLocation(60*i, pintar);
boton.setVisible(true);
boton.setSize(50, 15);
panel.add(boton);
}
for(int j=0; j<this.columnas-1; j++){
pintar += 25;
for(int k=0; k<filas; k++){
JButton boton = new JButton(k+"");
boton.setLocation(60*k, pintar);
boton.setVisible(true);
boton.setSize(50, 15);
panel.add(boton);
}
}
this.setContentPane(panelIntroduccion);
pintar++;
}