
I want to control the size of the button, I use the setBounds method But there are no changes, and this is my code
public class levels extends JFrame implements ActionListener{
private static JLabel chooseLevel;
private static JButton easyPuzzle;
private static JButton mediumPuzzle;
private static JButton hardPuzzle;
this main cod
public static void main(String[]args){
levels level = new levels();
level.setBounds(400, 190, 450, 450);
level.setVisible(true);
level.setResizable(false);
level.setTitle("Puzzle Number : New Game");
Container for adding components
Container cN = level.getContentPane(); // Container to add components for farme 1
GridLayout gN = new GridLayout(0,1,10,20); //object from GridLayout
cN.setLayout(gN);
levels.chooseLevel = new JLabel(" Choose a level :");
levels.easyPuzzle = new JButton("Easy puzzle from ( 1 - to -15)");
levels.mediumPuzzle = new JButton("Medium Puzzle from (1- to- 29)");
levels.hardPuzzle = new JButton("Hard Puzzle from (1- to- 59)");
//add components for frame
cN.add(chooseLevel);
cN.add(easyPuzzle);
cN.add(mediumPuzzle);
cN.add(hardPuzzle);
}
}
}
source
share