]> git.mxchange.org Git - addressbook-swing.git/blob - Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java
1a629c03fffe1ab7d50bf5594f61a5de0f19f4be
[addressbook-swing.git] / Addressbook / src / org / mxchange / addressbook / client / gui / AddressbookFrame.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.addressbook.client.gui;
18
19 import org.apache.logging.log4j.LogManager;
20 import org.apache.logging.log4j.Logger;
21 import org.mxchange.addressbook.application.Application;
22 import org.mxchange.addressbook.client.Client;
23 import org.mxchange.addressbook.manager.contact.ManageableContact;
24
25 /**
26  *
27  * @author Roland Haeder
28  */
29 public class AddressbookFrame extends javax.swing.JFrame implements ClientFrame {
30     /**
31      * Class' logger
32      */
33     private final Logger LOG;
34
35     /**
36      * Client instance
37      */
38     private final Client client;
39
40     /**
41      * Initialize object
42      */
43     {
44         LOG = LogManager.getLogger(this);
45     }
46
47     /**
48      * Creates an instance of this frame with a client instance
49      * @param client 
50      */
51     public AddressbookFrame (final Client client) {
52         // Debug line
53         this.getLogger().debug("Initializing Swing frame ...");
54
55         // Init components
56         initComponents();
57
58         // Set client here
59         this.client = client;
60     }
61
62     @Override
63     public Application getApplication () {
64         throw new UnsupportedOperationException("Not implemented.");
65     }
66
67     @Override
68     public final Client getClient () {
69         return this.client;
70     }
71
72     @Override
73     public ManageableContact getContactManager () {
74         throw new UnsupportedOperationException("Not implemented.");
75     }
76
77     /**
78      * This method is called from within the constructor to initialize the form.
79      * WARNING: Do NOT modify this code. The content of this method is always
80      * regenerated by the Form Editor.
81      */
82     @SuppressWarnings ("unchecked")
83     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
84     private void initComponents() {
85
86         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
87
88         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
89         getContentPane().setLayout(layout);
90         layout.setHorizontalGroup(
91             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
92             .addGap(0, 400, Short.MAX_VALUE)
93         );
94         layout.setVerticalGroup(
95             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
96             .addGap(0, 300, Short.MAX_VALUE)
97         );
98
99         pack();
100     }// </editor-fold>//GEN-END:initComponents
101
102     /**
103      * Initializes the frame
104      */
105     @Override
106     public void initFrame (final Client client) {
107         /*
108          * Set the Nimbus look and feel
109          */
110         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
111         /*
112          * If Nimbus (introduced in Java SE 6) is not available, stay with the
113          * default look and feel. For details see
114          * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
115          */
116         try {
117             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
118                 if ("Nimbus".equals(info.getName())) {
119                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
120                     break;
121                 }
122             }
123         } catch (final ClassNotFoundException ex) {
124             this.getLogger().catching(ex);
125         } catch (final InstantiationException ex) {
126             this.getLogger().catching(ex);
127         } catch (final IllegalAccessException ex) {
128             this.getLogger().catching(ex);
129         } catch (final javax.swing.UnsupportedLookAndFeelException ex) {
130             this.getLogger().catching(ex);
131         }
132         //</editor-fold>
133
134         // Debug line
135         this.getLogger().debug("Displaying form ...");
136
137         /*
138          * Create and display the form
139          */
140         java.awt.EventQueue.invokeLater(new Runnable() {
141             @Override
142             public void run () {
143                 new AddressbookFrame(client).setVisible(true);
144             }
145         });
146     }
147
148     /**
149      * Getter for logger
150      *
151      * @return Logger
152      */
153     protected final Logger getLogger () {
154         return this.LOG;
155     }
156
157     // Variables declaration - do not modify//GEN-BEGIN:variables
158     // End of variables declaration//GEN-END:variables
159 }