From c28ffed891227798e1a28a6814ba7a870821b2ca Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 24 Jul 2015 08:35:54 +0200 Subject: [PATCH] =?utf8?q?Introduced=20initMenuSystem()=20which=20initiali?= =?utf8?q?zes=20whole=20menu=20bar=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../client/gui/AddressbookFrame.java | 64 +++++++++++++++---- .../localization/bundle_de_DE.properties | 4 +- .../localization/bundle_en_US.properties | 4 +- 3 files changed, 56 insertions(+), 16 deletions(-) diff --git a/Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java b/Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java index 67968464..0cd0a3fc 100644 --- a/Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java +++ b/Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java @@ -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); } } diff --git a/Addressbook/src/org/mxchange/addressbook/localization/bundle_de_DE.properties b/Addressbook/src/org/mxchange/addressbook/localization/bundle_de_DE.properties index 1a68562c..29fec7da 100644 --- a/Addressbook/src/org/mxchange/addressbook/localization/bundle_de_DE.properties +++ b/Addressbook/src/org/mxchange/addressbook/localization/bundle_de_DE.properties @@ -13,7 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -AddressbookFrame.addOwn.text=Eigene Adresse hinzuf\u00fcgen AddressbookFrame.menu.file.text=Datei AddressbookFrame.statusLabel.initializing.text=Initialisiere ... AddressbookFrame.statusLabel.done.text=Fertig. @@ -21,4 +20,5 @@ AddressbookFrame.statusLabel.shutdown.text=Shuttting down ... AddressbookFrame.menuItem.exitProgram.toolTipText=Beendet das Programm und speichert alle Einstellungen ab. AddressbookFrame.menuItem.exitProgram.text=Programm beenden AddressbookFrame.menu.addressbook.text=Adressbuch -AddressbookFrame.addOwnData.toolTipText=Erlaubt das Hinzuf\u00fcgen eigener Daten. +AddressbookFrame.menuItem.addOwnData.text=Eigene Adresse hinzuf\u00fcgen +AddressbookFrame.menuItem.addOwnData.toolTipText=Erlaubt das Hinzuf\u00fcgen eigener Daten. diff --git a/Addressbook/src/org/mxchange/addressbook/localization/bundle_en_US.properties b/Addressbook/src/org/mxchange/addressbook/localization/bundle_en_US.properties index b3853fb1..4def06bf 100644 --- a/Addressbook/src/org/mxchange/addressbook/localization/bundle_en_US.properties +++ b/Addressbook/src/org/mxchange/addressbook/localization/bundle_en_US.properties @@ -13,7 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -AddressbookFrame.addOwn.text=Add own address AddressbookFrame.menu.file.text=File AddressbookFrame.statusLabel.initializing.text=Initializing ... AddressbookFrame.statusLabel.done.text=Done. @@ -21,4 +20,5 @@ AddressbookFrame.statusLabel.shutdown.text=Shuttting down ... AddressbookFrame.menuItem.exitProgram.toolTipText=Exits the program and saves all data. AddressbookFrame.menuItem.exitProgram.text=Exit program AddressbookFrame.addressbookMenu.text=Addressbook -AddressbookFrame.addOwnData.toolTipText=Allows the user to add own address data +AddressbookFrame.menuItem.addOwnData.text=Add own address +AddressbookFrame.menuItem.addOwnData.toolTipText=Allows the user to add own address data -- 2.39.5