public class Menu extends JFrame implements ActionListener{
// JButtons fürs Menü erstellen
private JButton start;
private JButton settings;
private JButton info;
private JButton exit;
// Konstruktor für die Menu-GUI
private Menu(String title){
super(title);
start = new JButton("Spiel starten");
start.setBounds(120,40,160,40);
start.addActionListener(this);
add(start);
settings = new JButton("Einstellungen");
settings.setBounds(120,120,160,40);
settings.addActionListener(this);
add(settings);
info = new JButton("Credits");
info.setBounds(120,200,160,40);
info.addActionListener(this);
add(info);
exit = new JButton("Ende");
exit.setBounds(120,280,160,40);
exit.addActionListener(this);
add(exit);
}
// Actionevents für die JButtons
public void actionPerformed(ActionEvent e){
if(e.getSource()== start){
new Window();
}
elseif(e.getSource()== info){
Object[] options ={"OK"};
JOptionPane.showOptionDialog(null,"Programmiert von Chris :)","Information", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
}
elseif(e.getSource()== settings){
// settings();
}
elseif(e.getSource()== exit){
System.exit(0);
}
}
// Platzhalter für den Menüpunkt: Einstellungen
//
// public static void settings() {
//
// }
// Startpunkt fürs Programm: Ruft den Konstruktor auf und passt ihn an