From 7e2ecb2abf5a875c4445c1f462d6223a0f5baa6e Mon Sep 17 00:00:00 2001 From: fdai6499 Date: Wed, 11 Jan 2023 17:10:15 +0100 Subject: [PATCH] DTSUD-62 Implemented Sandbox MenuItem with new Frame starting SandboxFrame.java on action --- src/main/java/src/MainFrame.java | 10 ++++++++++ src/main/java/src/SandboxFrame.java | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/main/java/src/SandboxFrame.java diff --git a/src/main/java/src/MainFrame.java b/src/main/java/src/MainFrame.java index 0b719e2..3f5f6ad 100644 --- a/src/main/java/src/MainFrame.java +++ b/src/main/java/src/MainFrame.java @@ -136,6 +136,7 @@ public class MainFrame extends JFrame { JMenu m_menu=new JMenu("Sudoku"); JMenu m_submenu=new JMenu("Neues Spiel"); JMenuItem menu_i7=new JMenuItem("Speichern"); + JMenuItem sandbox=new JMenuItem("Sandbox"); JMenuItem menu_i1=new JMenuItem("Nochmal"); JMenuItem menu_i2=new JMenuItem("Tipp"); JMenuItem menu_i4=new JMenuItem("Einfach"); @@ -145,6 +146,7 @@ public class MainFrame extends JFrame { m_menu.add(menu_i1); m_menu.add(menu_i2); m_menu.add(menu_i7); + m_menu.add(sandbox); m_submenu.add(menu_i4); m_submenu.add(menu_i5); m_submenu.add(menu_i6); @@ -161,6 +163,14 @@ public class MainFrame extends JFrame { }); m_menu_help.add(help); + sandbox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + SandboxFrame sandboxFrame = new SandboxFrame(); + sandboxFrame.run(); + } + }); + menu_mb.add(m_menu); menu_mb.add(m_menu_help); diff --git a/src/main/java/src/SandboxFrame.java b/src/main/java/src/SandboxFrame.java new file mode 100644 index 0000000..0d2a89a --- /dev/null +++ b/src/main/java/src/SandboxFrame.java @@ -0,0 +1,15 @@ +package src; + +import javax.swing.*; + +public class SandboxFrame extends JFrame { + + public void run() { + + this.setLayout(null); + this.setVisible(true); + this.setBounds(400, 200, 500, 500); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + } +}