]> git.mxchange.org Git - addressbook-swing.git/commitdiff
The NetBeans-created GUI was buggy, maybe because of the .form file. So I better...
authorRoland Haeder <roland@mxchange.org>
Thu, 23 Jul 2015 10:57:21 +0000 (12:57 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 23 Jul 2015 10:57:21 +0000 (12:57 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
Addressbook/src/org/mxchange/addressbook/BaseFrameworkSystem.java
Addressbook/src/org/mxchange/addressbook/FrameAlreadyInitializedException.java [new file with mode: 0644]
Addressbook/src/org/mxchange/addressbook/FrameworkInterface.java
Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.form [deleted file]
Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java
Addressbook/src/org/mxchange/addressbook/client/gui/ClientFrame.java
Addressbook/src/org/mxchange/addressbook/client/gui/SwingClient.java
Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java
Addressbook/src/org/mxchange/addressbook/localization/bundle_de_DE.properties
Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java

index e34fe66653fe414a4a6a47261663de483bb2e6e2..680474db064288d1de4d9e47f98835ed158060be 100644 (file)
@@ -39,6 +39,11 @@ public class BaseFrameworkSystem implements FrameworkInterface {
      */\r
     private Application application;\r
 \r
+    /**\r
+     * Bundle instance\r
+     */\r
+    private final ResourceBundle bundle;\r
+\r
     /**\r
      * Client instance\r
      */\r
@@ -54,10 +59,6 @@ public class BaseFrameworkSystem implements FrameworkInterface {
      */\r
     private String tableName;\r
 \r
-    /**\r
-     * Bundle instance\r
-     */\r
-    private final ResourceBundle bundle;\r
 \r
     /**\r
      * Initialize object\r
@@ -153,4 +154,13 @@ public class BaseFrameworkSystem implements FrameworkInterface {
     protected final void setTableName (final String tableName) {\r
        this.tableName = tableName;\r
     }\r
+\r
+    /**\r
+     * Getter for bundle instance\r
+     * \r
+     * @return Resource bundle\r
+     */\r
+    protected ResourceBundle getBundle () {\r
+       return this.bundle;\r
+    }\r
 }\r
diff --git a/Addressbook/src/org/mxchange/addressbook/FrameAlreadyInitializedException.java b/Addressbook/src/org/mxchange/addressbook/FrameAlreadyInitializedException.java
new file mode 100644 (file)
index 0000000..1709f0b
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class FrameAlreadyInitializedException extends Exception {
+
+    /**
+     * Default constructor
+     */
+    public FrameAlreadyInitializedException () {
+    }
+    
+}
index ae1c570b247ab52c1b12c9c3b6777c8041bd585a..2158bdbbd6d19f22f1e6b04fd423702d3c498e6e 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (C) 2015 KLC\r
+ * Copyright (C) 2015 Roland Haeder\r
  *\r
  * This program is free software: you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
@@ -22,7 +22,7 @@ import org.mxchange.addressbook.manager.contact.ManageableContact;
 \r
 /**\r
  *\r
- * @author KLC\r
+ * @author Roland Haeder\r
  */\r
 public interface FrameworkInterface {\r
 \r
diff --git a/Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.form b/Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.form
deleted file mode 100644 (file)
index d6899f3..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
-  <NonVisualComponents>
-    <Menu class="javax.swing.JMenuBar" name="menuBar">
-      <Properties>
-        <Property name="name" type="java.lang.String" value="menuBar" noResource="true"/>
-      </Properties>
-      <SubComponents>
-        <Menu class="javax.swing.JMenu" name="mainMenu">
-          <Properties>
-            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-              <ResourceString bundle="org/mxchange/addressbook/client/gui/Bundle.properties" key="AddressbookFrame.text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
-            </Property>
-            <Property name="focusable" type="boolean" value="false"/>
-            <Property name="name" type="java.lang.String" value="" noResource="true"/>
-          </Properties>
-          <SubComponents>
-            <MenuItem class="javax.swing.JMenuItem" name="exitProgram">
-              <Properties>
-                <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
-                  <KeyStroke key="Alt+X"/>
-                </Property>
-                <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-                  <ResourceString bundle="org/mxchange/addressbook/localization/bundle.properties" key="AddressbookFrame.exitProgram.text_1" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
-                </Property>
-                <Property name="name" type="java.lang.String" value="exitProgram" noResource="true"/>
-              </Properties>
-              <Events>
-                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitProgramActionPerformed"/>
-              </Events>
-            </MenuItem>
-          </SubComponents>
-        </Menu>
-        <Menu class="javax.swing.JMenu" name="addressbookMenu">
-          <Properties>
-            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-              <ResourceString bundle="org/mxchange/addressbook/localization/bundle.properties" key="AddressbookFrame.addressbookMenu.text_1" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
-            </Property>
-            <Property name="name" type="java.lang.String" value="addressbookMenu" noResource="true"/>
-          </Properties>
-          <SubComponents>
-            <MenuItem class="javax.swing.JMenuItem" name="addOwnData">
-              <Properties>
-                <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-                  <ResourceString bundle="org/mxchange/addressbook/client/gui/Bundle.properties" key="AddressbookFrame.addOwn.text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
-                </Property>
-                <Property name="name" type="java.lang.String" value="addOwn" noResource="true"/>
-              </Properties>
-              <AccessibilityProperties>
-                <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-                  <ResourceString bundle="org/mxchange/addressbook/localization/bundle.properties" key="AddressbookFrame.addOwnData.AccessibleContext.accessibleName_1" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
-                </Property>
-              </AccessibilityProperties>
-              <Events>
-                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addOwnDataActionPerformed"/>
-              </Events>
-            </MenuItem>
-          </SubComponents>
-        </Menu>
-      </SubComponents>
-    </Menu>
-  </NonVisualComponents>
-  <Properties>
-    <Property name="defaultCloseOperation" type="int" value="0"/>
-    <Property name="title" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
-      <Connection code="AddressbookApplication.printableTitle()" type="code"/>
-    </Property>
-    <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-      <Color id="Standardcursor"/>
-    </Property>
-    <Property name="name" type="java.lang.String" value="main" noResource="true"/>
-  </Properties>
-  <SyntheticProperties>
-    <SyntheticProperty name="menuBar" type="java.lang.String" value="menuBar"/>
-    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
-    <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
-  </SyntheticProperties>
-  <Events>
-    <EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="exitProgram"/>
-    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="windowClosing"/>
-  </Events>
-  <AuxValues>
-    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
-    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/>
-    <AuxValue name="FormSettings_formBundle" type="java.lang.String" value="org/mxchange/addressbook/localization/bundle"/>
-    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
-    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
-    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
-    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
-  </AuxValues>
-
-  <Layout>
-    <DimensionLayout dim="0">
-      <Group type="103" groupAlignment="0" attributes="0">
-          <Component id="statusPanel" max="32767" attributes="0"/>
-          <Component id="listAddressesPanel" alignment="0" pref="700" max="32767" attributes="0"/>
-          <Component id="toolBar" alignment="0" max="32767" attributes="0"/>
-      </Group>
-    </DimensionLayout>
-    <DimensionLayout dim="1">
-      <Group type="103" groupAlignment="0" attributes="0">
-          <Group type="102" alignment="1" attributes="0">
-              <Component id="toolBar" min="-2" pref="25" max="-2" attributes="0"/>
-              <EmptySpace max="-2" attributes="0"/>
-              <Component id="listAddressesPanel" min="-2" max="-2" attributes="0"/>
-              <EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
-              <Component id="statusPanel" min="-2" pref="23" max="-2" attributes="0"/>
-          </Group>
-      </Group>
-    </DimensionLayout>
-  </Layout>
-  <SubComponents>
-    <Container class="javax.swing.JPanel" name="statusPanel">
-      <Properties>
-        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
-          <Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
-            <EtchetBorder>
-              <Color PropertyName="highlight" blue="c0" green="c0" id="lightGray" palette="1" red="c0" type="palette"/>
-              <Color PropertyName="shadow" blue="99" green="99" red="99" type="rgb"/>
-            </EtchetBorder>
-          </Border>
-        </Property>
-        <Property name="autoscrolls" type="boolean" value="true"/>
-        <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-          <Color id="Standardcursor"/>
-        </Property>
-        <Property name="focusable" type="boolean" value="false"/>
-        <Property name="name" type="java.lang.String" value="status" noResource="true"/>
-      </Properties>
-      <AccessibilityProperties>
-        <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-          <ResourceString bundle="org/mxchange/addressbook/client/gui/Bundle.properties" key="AddressbookFrame.status.AccessibleContext.accessibleName" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
-        </Property>
-        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-          <ResourceString bundle="org/mxchange/addressbook/client/gui/Bundle.properties" key="AddressbookFrame.status.AccessibleContext.accessibleDescription" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
-        </Property>
-      </AccessibilityProperties>
-
-      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
-        <Property name="axis" type="int" value="0"/>
-      </Layout>
-      <SubComponents>
-        <Component class="javax.swing.JLabel" name="statusLabel">
-          <Properties>
-            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-              <ResourceString bundle="org/mxchange/addressbook/localization/bundle.properties" key="AddressbookFrame.statusLabel.text_1" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
-            </Property>
-            <Property name="horizontalTextPosition" type="int" value="2"/>
-            <Property name="name" type="java.lang.String" value="statusLabel" noResource="true"/>
-          </Properties>
-        </Component>
-      </SubComponents>
-    </Container>
-    <Container class="javax.swing.JScrollPane" name="listAddressesPanel">
-      <Properties>
-        <Property name="name" type="java.lang.String" value="listAddressesPanel" noResource="true"/>
-      </Properties>
-      <AuxValues>
-        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
-      </AuxValues>
-
-      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
-      <SubComponents>
-        <Component class="javax.swing.JTable" name="addressesTable">
-          <Properties>
-            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
-              <Connection code="new AddressTableModel(this.getClient())" type="code"/>
-            </Property>
-            <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
-              <TableColumnModel selectionModel="2"/>
-            </Property>
-            <Property name="columnSelectionAllowed" type="boolean" value="true"/>
-            <Property name="fillsViewportHeight" type="boolean" value="true"/>
-            <Property name="focusable" type="boolean" value="false"/>
-            <Property name="name" type="java.lang.String" value="addressesTable" noResource="true"/>
-            <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
-              <TableHeader reorderingAllowed="true" resizingAllowed="true"/>
-            </Property>
-          </Properties>
-        </Component>
-      </SubComponents>
-    </Container>
-    <Container class="javax.swing.JToolBar" name="toolBar">
-      <Properties>
-        <Property name="floatable" type="boolean" value="false"/>
-        <Property name="rollover" type="boolean" value="true"/>
-        <Property name="name" type="java.lang.String" value="toolBar" noResource="true"/>
-      </Properties>
-
-      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
-    </Container>
-  </SubComponents>
-</Form>
index 451d52503e4e22f30bfca99fd27b6639897dc03d..29151b1a1460ec185dd549b5bea0a20b6f2983c1 100644 (file)
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.client.gui;
-
-import java.awt.Color;
-import java.awt.Cursor;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.ResourceBundle;
-import javax.swing.BorderFactory;
-import javax.swing.BoxLayout;
-import javax.swing.GroupLayout;
-import javax.swing.JLabel;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JToolBar;
-import javax.swing.KeyStroke;
-import javax.swing.LayoutStyle;
-import javax.swing.ListSelectionModel;
-import javax.swing.SwingConstants;
-import javax.swing.UIManager;
-import javax.swing.WindowConstants;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.mxchange.addressbook.application.AddressbookApplication;
-import org.mxchange.addressbook.application.Application;
-import org.mxchange.addressbook.client.Client;
-import org.mxchange.addressbook.manager.contact.ManageableContact;
-import org.mxchange.addressbook.model.address.AddressTableModel;
-
-/**
- *
- * @author Roland Haeder
- */
-public class AddressbookFrame extends javax.swing.JFrame implements ClientFrame {
-    /**
-     * Class' logger
-     */
-    private final Logger LOG;
-
-    /**
-     * Client instance
-     */
-    private final Client client;
-
-    /**
-     * Own instance
-     */
-    private static ClientFrame self;
-
-    /**
-     * Bundle instance
-     */
-    private final ResourceBundle bundle;
-
-    /**
-     * Initialize object
-     */
-    {
-       LOG = LogManager.getLogger(this);
-       bundle = ResourceBundle.getBundle("org/mxchange/addressbook/localization/bundle"); // NOI18N
-    }
-
-    /**
-     * Creates an instance of this frame with a client instance
-     * @param client 
-     */
-    private AddressbookFrame (final Client client) {
-       // Debug line
-       this.getLogger().debug("Initializing Swing frame ...");
-
-       // Set client here
-       this.client = client;
-    }
-
-    @Override
-    public Application getApplication () {
-       throw new UnsupportedOperationException("Not implemented.");
-    }
-
-    @Override
-    public final Client getClient () {
-       return this.client;
-    }
-
-    @Override
-    public ManageableContact getContactManager () {
-       throw new UnsupportedOperationException("Not implemented.");
-    }
-
-    @Override
-    public void initFrame () {
-       // Init components
-       this.initComponents();
-    }
-
-    /**
-     * This method is called from within the constructor to initialize the form.
-     * WARNING: Do NOT modify this code. The content of this method is always
-     * regenerated by the Form Editor.
-     */
-    @SuppressWarnings ("unchecked")
-    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
-    private void initComponents() {
-
-        statusPanel = new JPanel();
-        statusLabel = new JLabel();
-        listAddressesPanel = new JScrollPane();
-        addressesTable = new JTable();
-        toolBar = new JToolBar();
-        menuBar = new JMenuBar();
-        mainMenu = new JMenu();
-        exitProgram = new JMenuItem();
-        addressbookMenu = new JMenu();
-        addOwnData = new JMenuItem();
-
-        setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
-        setTitle(AddressbookApplication.printableTitle());
-        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
-        setName("main"); // NOI18N
-        addWindowListener(new WindowAdapter() {
-            public void windowClosed(WindowEvent evt) {
-                exitProgram(evt);
-            }
-            public void windowClosing(WindowEvent evt) {
-                AddressbookFrame.this.windowClosing(evt);
-            }
-        });
-
-        statusPanel.setBorder(BorderFactory.createEtchedBorder(Color.lightGray, new Color(153, 153, 153)));
-        statusPanel.setAutoscrolls(true);
-        statusPanel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
-        statusPanel.setFocusable(false);
-        statusPanel.setName("status"); // NOI18N
-        statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
-
-        ResourceBundle bundle = ResourceBundle.getBundle("org/mxchange/addressbook/localization/bundle"); // NOI18N
-        statusLabel.setText(bundle.getString("AddressbookFrame.statusLabel.text_1")); // NOI18N
-        statusLabel.setHorizontalTextPosition(SwingConstants.LEFT);
-        statusLabel.setName("statusLabel"); // NOI18N
-        statusPanel.add(statusLabel);
-
-        listAddressesPanel.setName("listAddressesPanel"); // NOI18N
-
-        addressesTable.setModel(new AddressTableModel(this.getClient()));
-        addressesTable.setColumnSelectionAllowed(true);
-        addressesTable.setFillsViewportHeight(true);
-        addressesTable.setFocusable(false);
-        addressesTable.setName("addressesTable"); // NOI18N
-        listAddressesPanel.setViewportView(addressesTable);
-        addressesTable.getColumnModel().getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
-
-        toolBar.setFloatable(false);
-        toolBar.setRollover(true);
-        toolBar.setName("toolBar"); // NOI18N
-
-        menuBar.setName("menuBar"); // NOI18N
-
-        ResourceBundle bundle1 = ResourceBundle.getBundle("org/mxchange/addressbook/client/gui/Bundle"); // NOI18N
-        mainMenu.setText(bundle1.getString("AddressbookFrame.text")); // NOI18N
-        mainMenu.setFocusable(false);
-        mainMenu.setName(""); // NOI18N
-
-        exitProgram.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK));
-        exitProgram.setText(bundle.getString("AddressbookFrame.exitProgram.text_1")); // NOI18N
-        exitProgram.setName("exitProgram"); // NOI18N
-        exitProgram.addActionListener(new ActionListener() {
-            public void actionPerformed(ActionEvent evt) {
-                exitProgramActionPerformed(evt);
-            }
-        });
-        mainMenu.add(exitProgram);
-
-        menuBar.add(mainMenu);
-
-        addressbookMenu.setText(bundle.getString("AddressbookFrame.addressbookMenu.text_1")); // NOI18N
-        addressbookMenu.setName("addressbookMenu"); // NOI18N
-
-        addOwnData.setText(bundle1.getString("AddressbookFrame.addOwn.text")); // NOI18N
-        addOwnData.setName("addOwn"); // NOI18N
-        addOwnData.addActionListener(new ActionListener() {
-            public void actionPerformed(ActionEvent evt) {
-                addOwnDataActionPerformed(evt);
-            }
-        });
-        addressbookMenu.add(addOwnData);
-        addOwnData.getAccessibleContext().setAccessibleName(bundle.getString("AddressbookFrame.addOwnData.AccessibleContext.accessibleName_1")); // NOI18N
-
-        menuBar.add(addressbookMenu);
-
-        setJMenuBar(menuBar);
-
-        GroupLayout layout = new GroupLayout(getContentPane());
-        getContentPane().setLayout(layout);
-        layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
-            .addComponent(statusPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-            .addComponent(listAddressesPanel, GroupLayout.DEFAULT_SIZE, 700, Short.MAX_VALUE)
-            .addComponent(toolBar, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-        );
-        layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
-            .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
-                .addComponent(toolBar, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
-                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(listAddressesPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-                .addGap(1, 1, 1)
-                .addComponent(statusPanel, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE))
-        );
-
-        statusPanel.getAccessibleContext().setAccessibleName(bundle1.getString("AddressbookFrame.status.AccessibleContext.accessibleName")); // NOI18N
-        statusPanel.getAccessibleContext().setAccessibleDescription(bundle1.getString("AddressbookFrame.status.AccessibleContext.accessibleDescription")); // NOI18N
-
-        pack();
-    }// </editor-fold>//GEN-END:initComponents
-
-    private void exitProgramActionPerformed(ActionEvent evt) {//GEN-FIRST:event_exitProgramActionPerformed
-        // Close application instance
-       dispose();
-    }//GEN-LAST:event_exitProgramActionPerformed
-
-    private void addOwnDataActionPerformed(ActionEvent evt) {//GEN-FIRST:event_addOwnDataActionPerformed
-        // Asks the user to enter own data
-       this.getClient().getContactManager().doEnterOwnData();
-    }//GEN-LAST:event_addOwnDataActionPerformed
-
-    private void windowClosing(WindowEvent evt) {//GEN-FIRST:event_windowClosing
-        // TODO add your handling code here:
-       dispose();
-    }//GEN-LAST:event_windowClosing
-
-    private void exitProgram(WindowEvent evt) {//GEN-FIRST:event_exitProgram
-        // TODO add your handling code here:
-       this.getClient().getApplication().doShutdown();
-    }//GEN-LAST:event_exitProgram
-
-    /**
-     * Setups the frame
-     * 
-     * @param client Client instance
-     */
-    @Override
-    public void setupFrame (final Client client) {
-       // Has the user entered own data?
-       if (this.getClient().getContactManager().isOwnContactAdded()) {
-           // Debug message
-           this.getLogger().debug("Disabling menus: isOwnContactAdded()=false");
-
-           // Not entered yet, so enable menu
-           addOwnData.setEnabled(false);
-       }
-
-       /*
-        * Set the Nimbus look and feel
-        */
-       //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
-       /*
-        * If Nimbus (introduced in Java SE 6) is not available, stay with the
-        * default look and feel. For details see
-        * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
-        */
-       try {
-           for (UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
-               if ("Nimbus".equals(info.getName())) {
-                   UIManager.setLookAndFeel(info.getClassName());
-                   break;
-               }
-           }
-       } catch (final ClassNotFoundException ex) {
-           this.getLogger().catching(ex);
-       } catch (final InstantiationException ex) {
-           this.getLogger().catching(ex);
-       } catch (final IllegalAccessException ex) {
-           this.getLogger().catching(ex);
-       } catch (final javax.swing.UnsupportedLookAndFeelException ex) {
-           this.getLogger().catching(ex);
-       }
-        //</editor-fold>
-
-       // All done here
-       statusLabel.setText(bundle.getString("AddressbookFrame.status.done.text"));
-
-       // Debug line
-       this.getLogger().debug("Displaying form ...");
-
-       /*
-        * Create and display the form
-        */
-       java.awt.EventQueue.invokeLater(new Runnable() {
-           @Override
-           public void run () {
-               AddressbookFrame.getSelfInstance(client).setVisible(true);
-           }
-       });
-    }
-
-    /**
-     * Singelton getter for this frame instance.
-     * 
-     * @param client Client instance
-     * @return Returns a singelton instance of this frame
-     */
-    public static final ClientFrame getSelfInstance (final Client client) {
-       // Is it set?
-       if (!(self instanceof ClientFrame)) {
-           // Create new instance
-           self = new AddressbookFrame(client);
-       }
-    
-       // Return instance
-       return self;
-    }
-
-    /**
-     * Getter for logger
-     *
-     * @return Logger
-     */
-    protected final Logger getLogger () {
-       return this.LOG;
-    }
-
-    // Variables declaration - do not modify//GEN-BEGIN:variables
-    private JMenuItem addOwnData;
-    private JMenu addressbookMenu;
-    private JTable addressesTable;
-    private JMenuItem exitProgram;
-    private JScrollPane listAddressesPanel;
-    private JMenu mainMenu;
-    private JMenuBar menuBar;
-    private JLabel statusLabel;
-    private JPanel statusPanel;
-    private JToolBar toolBar;
-    // End of variables declaration//GEN-END:variables
-}
+/*\r
+ * Copyright (C) 2015 Roland Haeder\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
+package org.mxchange.addressbook.client.gui;\r
+\r
+import javax.swing.JFrame;\r
+import org.mxchange.addressbook.BaseFrameworkSystem;\r
+import org.mxchange.addressbook.FrameAlreadyInitializedException;\r
+import org.mxchange.addressbook.application.AddressbookApplication;\r
+import org.mxchange.addressbook.client.Client;\r
+\r
+/**\r
+ *\r
+ * @author Roland Haeder\r
+ */\r
+public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame {\r
+\r
+    /**\r
+     * Own instance\r
+     */\r
+    private static ClientFrame self;\r
+\r
+    /**\r
+     * Singelton getter for this frame instance.\r
+     *\r
+     * @param client Client instance\r
+     * @return Returns a singelton instance of this frame\r
+     */\r
+    public static final ClientFrame getSelfInstance (final Client client) {\r
+       // Is it set?\r
+       if (!(self instanceof ClientFrame)) {\r
+           // Create new instance\r
+           self = new AddressbookFrame(client);\r
+       }\r
+       \r
+       // Return instance\r
+       return self;\r
+    }\r
+\r
+    /**\r
+     * Frame instance\r
+     */\r
+    private final JFrame frame;\r
+\r
+    /**\r
+     * Whether this frame has been initialized\r
+     */\r
+    private boolean isInitialized;\r
+\r
+    /**\r
+     * Creates an instance of this frame with a client instance\r
+     * @param client\r
+     */\r
+    private AddressbookFrame (final Client client) {\r
+       // Debug line\r
+       this.getLogger().debug("Initializing Swing frame ...");\r
+\r
+       // Set frame instance\r
+       this.frame = new JFrame(AddressbookApplication.printableTitle());\r
+\r
+       // Set client here\r
+       this.setClient(client);\r
+    }\r
+\r
+    @Override\r
+    public void setVisible (final boolean visible) {\r
+       throw new UnsupportedOperationException("Not supported yet.");\r
+    }\r
+\r
+    /**\r
+     * Setups the frame\r
+     * \r
+     * @param client Client instance\r
+     */\r
+    @Override\r
+    public void setupFrame (final Client client) {\r
+       // Has the user entered own data?\r
+       if (this.getClient().getContactManager().isOwnContactAdded()) {\r
+           // Debug message\r
+           this.getLogger().debug("Disabling menus: isOwnContactAdded()=false");\r
+\r
+           // Not entered yet, so enable menu\r
+           //addOwnData.setEnabled(false);\r
+       }\r
+\r
+       // All done here\r
+       //statusLabel.setText(bundle.getString("AddressbookFrame.status.done.text"));\r
+    }\r
+\r
+    /**\r
+     * Initalizes this frame. Having initComponents() exposed (publicly\r
+     * accessible) means that any other object can initialize components which\r
+     * you may not want.\r
+     * \r
+     * @throws org.mxchange.addressbook.FrameAlreadyInitializedException If this method has been called twice\r
+     */\r
+    @Override\r
+    public void initFrame () throws FrameAlreadyInitializedException {\r
+       // Has this frame been initialized?\r
+       if (this.isInitialized) {\r
+           // Throw exception\r
+           throw new FrameAlreadyInitializedException();\r
+       }\r
+\r
+       // Init components\r
+       this.initComponents();\r
+\r
+       // Set flag\r
+       this.isInitialized = true;\r
+    }\r
+\r
+    /**\r
+     * Initialize components\r
+     */\r
+    private void initComponents () {\r
+    }\r
+\r
+}\r
index 17318d4466b3907cf3172eb8a369ab37acb9d77f..06af9bb57af2cb05b262f18aa1172d7212c61eed 100644 (file)
@@ -16,6 +16,7 @@
  */\r
 package org.mxchange.addressbook.client.gui;\r
 \r
+import org.mxchange.addressbook.FrameAlreadyInitializedException;\r
 import org.mxchange.addressbook.FrameworkInterface;\r
 import org.mxchange.addressbook.client.Client;\r
 \r
@@ -42,6 +43,8 @@ public interface ClientFrame extends FrameworkInterface {
 \r
     /**\r
      * Initializes frame\r
+     * \r
+     * @throws org.mxchange.addressbook.FrameAlreadyInitializedException If this method has been called twice\r
      */\r
-    public void initFrame ();\r
+    public void initFrame () throws FrameAlreadyInitializedException;\r
 }\r
index 9ea4e8816fd677c7c6eac04c316cf04134291fe2..8992b3a1ebb621a54afb9499d6f829e79033fe25 100644 (file)
@@ -16,6 +16,7 @@
  */\r
 package org.mxchange.addressbook.client.gui;\r
 \r
+import org.mxchange.addressbook.FrameAlreadyInitializedException;\r
 import org.mxchange.addressbook.UnhandledUserChoiceException;\r
 import org.mxchange.addressbook.application.Application;\r
 import org.mxchange.addressbook.client.BaseClient;\r
@@ -138,8 +139,13 @@ public class SwingClient extends BaseClient implements Client {
        // Init contact manager here\r
        this.initContactManager();\r
 \r
-       // Init frame\r
-       this.frame.initFrame();\r
+       try {\r
+           // Init frame\r
+           this.frame.initFrame();\r
+       } catch (final FrameAlreadyInitializedException ex) {\r
+           this.getLogger().catching(ex);\r
+           System.exit(1);\r
+       }\r
 \r
        // Now start the frame\r
        this.frame.setupFrame(this);\r
index 78d4f0790bf582be22c1d40726c03c295b3f69f1..2a1ecb73ffd0bbf9d1f3605b063a71355379bf39 100644 (file)
@@ -28,11 +28,6 @@ import org.mxchange.addressbook.client.Client;
  * @since 0.0\r
  */\r
 public class BaseContact extends BaseFrameworkSystem {\r
-    /**\r
-     * Amount of columns\r
-     */\r
-    public static final int COLUMN_COUNT = 14;\r
-\r
     /**\r
      * Birth day\r
      */\r
index e4c5738bc998dabe616220346225f1ff5400feec..bbc3dbb89c45a9797f45b9dd9573e7a8a2e8a4c2 100644 (file)
@@ -26,7 +26,3 @@ AddressbookFrame.addOwnData.toolTipText=Erlaubt das Hinzuf\u00fcgen eigener Date
 AddressbookFrame.addOwnData.AccessibleContext.accessibleName=addOwn\r
 AddressbookFrame.addOwnData.AccessibleContext.accessibleDescription=\r
 AddressbookFrame.status.done.text=Fertig.\r
-AddressbookFrame.addOwnData.AccessibleContext.accessibleName_1=null\r
-AddressbookFrame.addressbookMenu.text_1=null\r
-AddressbookFrame.exitProgram.text_1=null\r
-AddressbookFrame.statusLabel.text_1=null\r
index e89b7081d72838f5fa4b38b23a3e3101be8a23d0..fefd2c1410e9473d13d7aadaf2e78764e1228931 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.List;\r
 import org.mxchange.addressbook.UnhandledUserChoiceException;\r
 import org.mxchange.addressbook.client.Client;\r
-import org.mxchange.addressbook.contact.BaseContact;\r
 import org.mxchange.addressbook.contact.Contact;\r
 import org.mxchange.addressbook.database.frontend.contact.ContactDatabaseFrontend;\r
 import org.mxchange.addressbook.database.frontend.contact.ContactWrapper;\r
@@ -37,6 +36,10 @@ import org.mxchange.addressbook.manager.BaseManager;
  * @version 0.0\r
  */\r
 public class ContactManager extends BaseManager implements ManageableContact {\r
+    /**\r
+     * Column name list\r
+     */\r
+    private final List<String> columnNames;\r
 \r
     /**\r
      * A ContactWrapper instance\r
@@ -48,6 +51,7 @@ public class ContactManager extends BaseManager implements ManageableContact {
      */\r
     private final List<Contact> contacts;\r
 \r
+\r
     /**\r
      * @param maxContacts Maximum allowed contacts\r
      * @param client Client instance to use\r
@@ -56,20 +60,26 @@ public class ContactManager extends BaseManager implements ManageableContact {
        // Always call super constructor first\r
        super();\r
 \r
+       // Set client instance\r
+       this.setClient(client);\r
+\r
        // Init contacts\r
        this.contacts = new ArrayList<>(maxContacts);\r
 \r
        // Init database connection\r
        this.contactDatabase = new ContactDatabaseFrontend(this);\r
 \r
+       // Initialize list\r
+       this.columnNames = new ArrayList<>(15);\r
+\r
+       // And fill it\r
+       this.fillColumnNamesFromBundle();\r
+\r
        // Read all entries\r
        this.contactDatabase.readAllContacts();\r
 \r
        // Debug message\r
        //* NOISY-DEBUG: */ this.getLogger().debug("client=" + client);\r
-\r
-       // Init client\r
-       this.setClient(client);\r
     }\r
 \r
     /**\r
@@ -364,11 +374,7 @@ public class ContactManager extends BaseManager implements ManageableContact {
 \r
     @Override\r
     public int getColumnCount () {\r
-       /*\r
-        * Return constant, may look useful. But without this, e.g. the\r
-        * AddressTableModel have a hard-coded value.\r
-        */\r
-       return BaseContact.COLUMN_COUNT;\r
+       return this.columnNames.size();\r
     }\r
 \r
     /**\r
@@ -463,6 +469,29 @@ public class ContactManager extends BaseManager implements ManageableContact {
        return this.contacts.size();\r
     }\r
 \r
+    /**\r
+     * Fills the column names array with strings from bundle\r
+     */\r
+    private void fillColumnNamesFromBundle () {\r
+       // First get an iterator from key set to iterate over\r
+       Iterator<String> iterator = this.getBundle().keySet().iterator();\r
+\r
+       // Then iterate over all\r
+       while (iterator.hasNext()) {\r
+           // Get next element\r
+           String key = iterator.next();\r
+\r
+           // Does the key start with ContactManager.columnName ?\r
+           if (key.startsWith("ContactManager.columnName")) {\r
+               // This is the wanted entry.\r
+               this.getLogger().debug(MessageFormat.format("key={0}", key));\r
+\r
+               // So add it\r
+               this.columnNames.add(this.getBundle().getString(key));\r
+           }\r
+       }\r
+    }\r
+\r
     /**\r
      * Flushes all entries by calling database backend\r
      */\r