I am a beginner. I am programming a Java game, and I am having trouble changing the size of the button buttonPlayAgain
. The size of the button does not change using the code below. How can I change the size of the button?
Here is my code:
public hoppa(IModele modele) {
super(new GridLayout(1, 1));
setSize(VueGrille.FACT * modele.getGrille().getLongueur(), 1);
Dimension dim = new Dimension(1, 1);
labMines = new JLabel();
labMines.setPreferredSize(dim);
add(labMines);
buttonPlayAgain = new JButton("New Game");
//buttonPlayAgain.setSize(1, 1);
buttonPlayAgain.setPreferredSize(new Dimension(50,50));
add(buttonPlayAgain);
labTimer = new JLabel();
labTimer.setPreferredSize(dim);
add(labTimer);
initValues(modele);
}