From 416e35f7e06f4689cccfd220bf1b4a20ffac54ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 10 Jan 2019 10:14:16 +0100 Subject: [PATCH] Add a menu to the main windows. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/MainWindowsView.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/MainWindowsView.java b/src/MainWindowsView.java index 2cda811..bc79511 100644 --- a/src/MainWindowsView.java +++ b/src/MainWindowsView.java @@ -1,5 +1,7 @@ import javax.swing.*; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.ArrayList; public class MainWindowsView extends JFrame { @@ -10,6 +12,19 @@ public class MainWindowsView extends JFrame { setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + //Create menu + JMenuBar menuBar = new JMenuBar(); + setJMenuBar(menuBar); + JMenu fileMenu = new JMenu("File"); + menuBar.add(fileMenu); + JMenuItem exit = new JMenuItem("Exit"); + exit.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.exit(0); + } + }); + fileMenu.add(exit); + //Main pane JPanel panel = new PersonView(); @@ -42,4 +57,4 @@ public class MainWindowsView extends JFrame { this.setVisible(true); } -} +} \ No newline at end of file -- 2.34.1