Hi I made some buttons align nicely next to each other but now I want them at the bottom of my panel/frame.
How can I do this? I thought about setalignment but that doesn't seem to work.
Thanks in advance:
public class mainMenu extends JFrame {
private JButton start, highscore, help, stoppen;
public mainMenu() {
super("Master Mind");
maakComponenten();
maakLayout();
toonFrame();
}
private void maakComponenten() {
start = new JButton("Start") {
{
setSize(150, 30);
setMaximumSize(getSize());
}
};
highscore = new JButton("Highscore") {
{
setSize(150, 30);
setMaximumSize(getSize());
}
};
help = new JButton("Help") {
{
setSize(150, 30);
setMaximumSize(getSize());
}
};
stoppen = new JButton("Stoppen") {
{
setSize(150, 30);
setMaximumSize(getSize());
}
};
}
private void maakLayout() {
JPanel hoofdmenu = new JPanel();
hoofdmenu.setLayout(new BoxLayout(hoofdmenu, BoxLayout.X_AXIS));
hoofdmenu.add(start);
hoofdmenu.add(highscore);
hoofdmenu.add(help);
hoofdmenu.add(stoppen);
super.add(hoofdmenu);
}
private void toonFrame() {
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setVisible(true);
setSize(500, 500);
}
public static void main(String[] args) {
new mainMenu();
}
}