Nur die besten Spiele ;3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.0 KiB

2 years ago
  1. package solitaer;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4. import javax.swing.JMenu;
  5. import javax.swing.JMenuBar;
  6. import javax.swing.JMenuItem;
  7. public class SolitaerMenue implements ActionListener{
  8. SolitaerGamePanel solitaerpanel;
  9. JMenuBar menuBar = new JMenuBar();
  10. JMenu menu = new JMenu("options");
  11. JMenuItem restart = new JMenuItem("restart");
  12. JMenuItem quit = new JMenuItem("quit");
  13. public SolitaerMenue(SolitaerGamePanel _panel) {
  14. solitaerpanel = _panel;
  15. this.restart.addActionListener(this);
  16. this.menu.add(restart);
  17. this.menu.addSeparator();
  18. this.quit.addActionListener(this);
  19. this.menu.add(quit);
  20. this.menuBar.add(menu);
  21. }
  22. public JMenuBar getMenue() {
  23. return menuBar;
  24. }
  25. @Override
  26. public void actionPerformed(ActionEvent e) {
  27. // TODO Auto-generated method stub
  28. if(e.getSource() == this.quit) {
  29. System.out.println("quit");
  30. System.exit(0);
  31. }
  32. if(e.getSource() == this.restart) {
  33. solitaerpanel.restartGame();
  34. }
  35. }
  36. }