]> git.mxchange.org Git - jaddressbook-lib.git/blob - Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java
The NetBeans-created GUI was buggy, maybe because of the .form file. So I better...
[jaddressbook-lib.git] / Addressbook / src / org / mxchange / addressbook / client / gui / AddressbookFrame.java
1 /*\r
2  * Copyright (C) 2015 Roland Haeder\r
3  *\r
4  * This program is free software: you can redistribute it and/or modify\r
5  * it under the terms of the GNU General Public License as published by\r
6  * the Free Software Foundation, either version 3 of the License, or\r
7  * (at your option) any later version.\r
8  *\r
9  * This program is distributed in the hope that it will be useful,\r
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12  * GNU General Public License for more details.\r
13  *\r
14  * You should have received a copy of the GNU General Public License\r
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
16  */\r
17 package org.mxchange.addressbook.client.gui;\r
18 \r
19 import javax.swing.JFrame;\r
20 import org.mxchange.addressbook.BaseFrameworkSystem;\r
21 import org.mxchange.addressbook.FrameAlreadyInitializedException;\r
22 import org.mxchange.addressbook.application.AddressbookApplication;\r
23 import org.mxchange.addressbook.client.Client;\r
24 \r
25 /**\r
26  *\r
27  * @author Roland Haeder\r
28  */\r
29 public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame {\r
30 \r
31     /**\r
32      * Own instance\r
33      */\r
34     private static ClientFrame self;\r
35 \r
36     /**\r
37      * Singelton getter for this frame instance.\r
38      *\r
39      * @param client Client instance\r
40      * @return Returns a singelton instance of this frame\r
41      */\r
42     public static final ClientFrame getSelfInstance (final Client client) {\r
43         // Is it set?\r
44         if (!(self instanceof ClientFrame)) {\r
45             // Create new instance\r
46             self = new AddressbookFrame(client);\r
47         }\r
48         \r
49         // Return instance\r
50         return self;\r
51     }\r
52 \r
53     /**\r
54      * Frame instance\r
55      */\r
56     private final JFrame frame;\r
57 \r
58     /**\r
59      * Whether this frame has been initialized\r
60      */\r
61     private boolean isInitialized;\r
62 \r
63     /**\r
64      * Creates an instance of this frame with a client instance\r
65      * @param client\r
66      */\r
67     private AddressbookFrame (final Client client) {\r
68         // Debug line\r
69         this.getLogger().debug("Initializing Swing frame ...");\r
70 \r
71         // Set frame instance\r
72         this.frame = new JFrame(AddressbookApplication.printableTitle());\r
73 \r
74         // Set client here\r
75         this.setClient(client);\r
76     }\r
77 \r
78     @Override\r
79     public void setVisible (final boolean visible) {\r
80         throw new UnsupportedOperationException("Not supported yet.");\r
81     }\r
82 \r
83     /**\r
84      * Setups the frame\r
85      * \r
86      * @param client Client instance\r
87      */\r
88     @Override\r
89     public void setupFrame (final Client client) {\r
90         // Has the user entered own data?\r
91         if (this.getClient().getContactManager().isOwnContactAdded()) {\r
92             // Debug message\r
93             this.getLogger().debug("Disabling menus: isOwnContactAdded()=false");\r
94 \r
95             // Not entered yet, so enable menu\r
96             //addOwnData.setEnabled(false);\r
97         }\r
98 \r
99         // All done here\r
100         //statusLabel.setText(bundle.getString("AddressbookFrame.status.done.text"));\r
101     }\r
102 \r
103     /**\r
104      * Initalizes this frame. Having initComponents() exposed (publicly\r
105      * accessible) means that any other object can initialize components which\r
106      * you may not want.\r
107      * \r
108      * @throws org.mxchange.addressbook.FrameAlreadyInitializedException If this method has been called twice\r
109      */\r
110     @Override\r
111     public void initFrame () throws FrameAlreadyInitializedException {\r
112         // Has this frame been initialized?\r
113         if (this.isInitialized) {\r
114             // Throw exception\r
115             throw new FrameAlreadyInitializedException();\r
116         }\r
117 \r
118         // Init components\r
119         this.initComponents();\r
120 \r
121         // Set flag\r
122         this.isInitialized = true;\r
123     }\r
124 \r
125     /**\r
126      * Initialize components\r
127      */\r
128     private void initComponents () {\r
129     }\r
130 \r
131 }\r