X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FMainWindowsView.java;h=c3688ba206e60bf9f7ef80b3bf9a145d71e8893e;hb=d119e60d58d8431de3ff29090d7048b0eb7d9f9e;hp=065c90d8050f0deb9203ce7733bb26b49b64c029;hpb=089fcbfccd75b77daf843b22e128beeee1d1dc07;p=Persons_Comparator.git diff --git a/src/MainWindowsView.java b/src/MainWindowsView.java index 065c90d..c3688ba 100644 --- a/src/MainWindowsView.java +++ b/src/MainWindowsView.java @@ -1,18 +1,32 @@ 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 { - MainWindowsView(String title) { + + MainWindowsView(String title, JPanel panel) { //Create and set up the window. setTitle(title); setSize(300, 300); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel panel = new PersonView(); + //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); - //Get all Swing/AWT primitive components in the views and add them to the panel. + //Get all Swing/AWT primitive components in the views and add them to the main panel. ArrayList components = new ArrayList<>(); for (int i = 0; i < panel.getComponentCount(); i++) { if ((panel.getComponent(i) instanceof Container)) { @@ -40,5 +54,4 @@ public class MainWindowsView extends JFrame { //this.pack(); this.setVisible(true); } - -} +} \ No newline at end of file