]> git.mxchange.org Git - jaddressbook-share-lib.git/blobdiff - Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java
Introduced initMenuSystem() which initializes whole menu bar
[jaddressbook-share-lib.git] / Addressbook / src / org / mxchange / addressbook / client / gui / AddressbookFrame.java
index 679684641897d4b3963daf725b13775f1612de93..0cd0a3fc48eb6dc3b99e1a531454ad1747e2c961 100644 (file)
@@ -78,6 +78,11 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
      */
     private JLabel statusLabel;
 
+    /**
+     * Frame instance
+     */
+    private JMenuItem addOwnItem;
+
     /**
      * Creates an instance of this frame with a client instance
      * 
@@ -119,7 +124,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
            this.getLogger().debug("Disabling menus: isOwnContactAdded()=false");
 
            // Not entered yet, so enable menu
-           //addOwnData.setEnabled(false);
+           this.addOwnItem.setEnabled(false);
        }
 
        // Make the frame visible
@@ -205,6 +210,26 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
        // Center window in middle of screen, instead of top-left corner
        this.frame.setLocationRelativeTo(null);
 
+       // Init menu system
+       initMenuSystem();
+
+       // Init status label (which needs to be updated
+       this.statusLabel = new JLabel(this.getBundle().getString("AddressbookFrame.statusLabel.initializing.text"));
+
+       // Init status bar in south
+       JPanel panel = new JPanel();
+       panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
+       panel.add(this.statusLabel);
+       panel.setBorder(BorderFactory.createEtchedBorder());
+
+       // Add panel to frame
+       this.frame.add(panel, BorderLayout.SOUTH);
+    }
+
+    /**
+     * Initializes the menu system
+     */
+    private void initMenuSystem () {
        // Init menu bar, menu and item instances
        JMenuBar menuBar = new JMenuBar();
        JMenu menu;
@@ -238,20 +263,35 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
        // Add menu -> menu bar
        menuBar.add(menu);
 
-       // Add menu bar -> frame
-       this.frame.add(menuBar, BorderLayout.NORTH);
+       // Init some menus:
+       // 2) Addressbook menu
+       menu = new JMenu(this.getBundle().getString("AddressbookFrame.menu.addressbook.text"));
 
-       // Init status label (which needs to be updated
-       this.statusLabel = new JLabel(this.getBundle().getString("AddressbookFrame.statusLabel.initializing.text"));
+       // 2.1) Add own data
+       this.addOwnItem = new JMenuItem(this.getBundle().getString("AddressbookFrame.menuItem.addOwnData.text"));
+       this.addOwnItem.setToolTipText(this.getBundle().getString("AddressbookFrame.menuItem.addOwnData.toolTipText"));
 
-       // Init status bar in south
-       JPanel panel = new JPanel();
-       panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
-       panel.add(this.statusLabel);
-       panel.setBorder(BorderFactory.createEtchedBorder());
+       // Add listener to exit menu
+       this.addOwnItem.addActionListener(new ActionListener() {
+           /**
+            * If the user has performed this action
+            *
+            * @param e An instance of an ActionEvent class
+            */
+           @Override
+           public void actionPerformed (final ActionEvent e) {
+               self.getClient().getContactManager().doEnterOwnData();
+           }
+       });
 
-       // Add panel to frame
-       this.frame.add(panel, BorderLayout.SOUTH);
+       // Add item -> menu
+       menu.add(this.addOwnItem);
+
+       // Add menu -> menu bar
+       menuBar.add(menu);
+
+       // Add menu bar -> frame
+       this.frame.add(menuBar, BorderLayout.NORTH);
     }
 
 }