From b8ad7aca0676b7a6343ca8953003cf3eaa27b098 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 6 Feb 2022 15:30:15 +0100 Subject: [PATCH] Add SolitaerMenue --- src/main/java/hauptmenue/GameWindow.java | 7 +++--- src/main/java/solitaer/SolitaerMenue.java | 30 +++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 src/main/java/solitaer/SolitaerMenue.java diff --git a/src/main/java/hauptmenue/GameWindow.java b/src/main/java/hauptmenue/GameWindow.java index a2c7479..7fe612d 100644 --- a/src/main/java/hauptmenue/GameWindow.java +++ b/src/main/java/hauptmenue/GameWindow.java @@ -5,18 +5,19 @@ import java.awt.Dimension; import javax.swing.JFrame; import solitaer.SolitaerGamePanel; +import solitaer.SolitaerMenue; public class GameWindow extends JFrame { - /** - * - */ private static final long serialVersionUID = 1L; private final SolitaerGamePanel gamePanel = new SolitaerGamePanel(); + + private SolitaerMenue smenue = new SolitaerMenue(); public GameWindow() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gamePanel.setPreferredSize(new Dimension(1180, 780)); + this.setJMenuBar(smenue.getMenue()); add(gamePanel); pack(); diff --git a/src/main/java/solitaer/SolitaerMenue.java b/src/main/java/solitaer/SolitaerMenue.java new file mode 100644 index 0000000..e2c854b --- /dev/null +++ b/src/main/java/solitaer/SolitaerMenue.java @@ -0,0 +1,30 @@ +package solitaer; + +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; + +public class SolitaerMenue { + + JMenuBar menuBar = new JMenuBar(); + + JMenu menu = new JMenu("options"); + + JMenuItem restart = new JMenuItem("restart"); + JMenuItem quit = new JMenuItem("quit"); + + public SolitaerMenue() { + + this.menu.add(restart); + this.menu.addSeparator(); + this.menu.add(quit); + + this.menuBar.add(menu); + + } + + public JMenuBar getMenue() { + return menuBar; + } + +}