From: Jérôme Benoit Date: Thu, 10 Jan 2019 09:14:16 +0000 (+0100) Subject: Add a menu to the main windows. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=416e35f7e06f4689cccfd220bf1b4a20ffac54ec;p=Persons_Comparator.git Add a menu to the main windows. Signed-off-by: Jérôme Benoit --- 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