Browse Source

Add MouseInput MenueRestart-Button

feature_solitaer_MenueBar
Alexander Hartung 3 years ago
parent
commit
d478ae0cc6
  1. 2
      src/main/java/hauptmenue/GameWindow.java
  2. 10
      src/main/java/solitaer/SolitaerMenue.java

2
src/main/java/hauptmenue/GameWindow.java

@ -12,7 +12,7 @@ public class GameWindow extends JFrame {
private static final long serialVersionUID = 1L;
private final SolitaerGamePanel gamePanel = new SolitaerGamePanel();
private SolitaerMenue smenue = new SolitaerMenue();
private SolitaerMenue smenue = new SolitaerMenue(gamePanel);
public GameWindow() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

10
src/main/java/solitaer/SolitaerMenue.java

@ -9,6 +9,8 @@ import javax.swing.JMenuItem;
public class SolitaerMenue implements ActionListener{
SolitaerGamePanel solitaerpanel;
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("options");
@ -16,7 +18,9 @@ public class SolitaerMenue implements ActionListener{
JMenuItem restart = new JMenuItem("restart");
JMenuItem quit = new JMenuItem("quit");
public SolitaerMenue() {
public SolitaerMenue(SolitaerGamePanel _panel) {
solitaerpanel = _panel;
this.restart.addActionListener(this);
this.menu.add(restart);
@ -41,6 +45,10 @@ public class SolitaerMenue implements ActionListener{
System.exit(0);
}
if(e.getSource() == this.restart) {
solitaerpanel.restartGame();
}
}
}
Loading…
Cancel
Save