2 * Copyright (C) 2015 Roland Haeder
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.
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.
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/>.
17 package org.mxchange.addressbook.client.gui;
19 import org.apache.logging.log4j.LogManager;
20 import org.apache.logging.log4j.Logger;
21 import org.mxchange.addressbook.application.AddressbookApplication;
22 import org.mxchange.addressbook.application.Application;
23 import org.mxchange.addressbook.client.Client;
24 import org.mxchange.addressbook.manager.contact.ManageableContact;
28 * @author Roland Haeder
30 public class AddressbookFrame extends javax.swing.JFrame implements ClientFrame {
34 private final Logger LOG;
39 private final Client client;
45 LOG = LogManager.getLogger(this);
49 * Creates an instance of this frame with a client instance
52 public AddressbookFrame (final Client client) {
54 this.getLogger().debug("Initializing Swing frame ...");
64 public Application getApplication () {
65 throw new UnsupportedOperationException("Not implemented.");
69 public final Client getClient () {
74 public ManageableContact getContactManager () {
75 throw new UnsupportedOperationException("Not implemented.");
79 * This method is called from within the constructor to initialize the form.
80 * WARNING: Do NOT modify this code. The content of this method is always
81 * regenerated by the Form Editor.
83 @SuppressWarnings ("unchecked")
84 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
85 private void initComponents() {
87 statusPane = new javax.swing.JScrollPane();
88 statusText = new javax.swing.JTextPane();
89 mainMenu = new javax.swing.JMenuBar();
90 jMenu1 = new javax.swing.JMenu();
91 jMenuItem1 = new javax.swing.JMenuItem();
92 jMenu2 = new javax.swing.JMenu();
94 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
95 setTitle(AddressbookApplication.printableTitle());
96 setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
97 setName("main"); // NOI18N
99 statusText.setBackground(new java.awt.Color(240, 240, 240));
100 java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/mxchange/addressbook/client/gui/Bundle"); // NOI18N
101 statusText.setText(bundle.getString("AddressbookFrame.status.text")); // NOI18N
102 statusText.setName("status"); // NOI18N
103 statusPane.setViewportView(statusText);
104 statusText.getAccessibleContext().setAccessibleName(bundle.getString("AddressbookFrame.status.AccessibleContext.accessibleName")); // NOI18N
106 jMenu1.setText(bundle.getString("AddressbookFrame.text")); // NOI18N
107 jMenu1.setFocusable(false);
108 jMenu1.setName(""); // NOI18N
110 jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK));
111 jMenuItem1.setText(bundle.getString("AddressbookFrame.jMenuItem1.text")); // NOI18N
112 jMenuItem1.setToolTipText(bundle.getString("AddressbookFrame.jMenuItem1.toolTipText")); // NOI18N
113 jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
114 public void actionPerformed(java.awt.event.ActionEvent evt) {
115 jMenuItem1ActionPerformed(evt);
118 jMenu1.add(jMenuItem1);
120 mainMenu.add(jMenu1);
122 jMenu2.setText(bundle.getString("AddressbookFrame.jMenu2.text")); // NOI18N
123 mainMenu.add(jMenu2);
125 setJMenuBar(mainMenu);
127 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
128 getContentPane().setLayout(layout);
129 layout.setHorizontalGroup(
130 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
131 .addComponent(statusPane, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
133 layout.setVerticalGroup(
134 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
135 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
136 .addGap(0, 257, Short.MAX_VALUE)
137 .addComponent(statusPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
141 }// </editor-fold>//GEN-END:initComponents
143 private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
144 // Close application instance
145 this.getClient().getApplication().doShutdown();
146 }//GEN-LAST:event_jMenuItem1ActionPerformed
149 * Initializes the frame
152 public void initFrame (final Client client) {
154 * Set the Nimbus look and feel
156 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
158 * If Nimbus (introduced in Java SE 6) is not available, stay with the
159 * default look and feel. For details see
160 * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
163 for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
164 if ("Nimbus".equals(info.getName())) {
165 javax.swing.UIManager.setLookAndFeel(info.getClassName());
169 } catch (final ClassNotFoundException ex) {
170 this.getLogger().catching(ex);
171 } catch (final InstantiationException ex) {
172 this.getLogger().catching(ex);
173 } catch (final IllegalAccessException ex) {
174 this.getLogger().catching(ex);
175 } catch (final javax.swing.UnsupportedLookAndFeelException ex) {
176 this.getLogger().catching(ex);
181 this.getLogger().debug("Displaying form ...");
184 * Create and display the form
186 java.awt.EventQueue.invokeLater(new Runnable() {
189 new AddressbookFrame(client).setVisible(true);
199 protected final Logger getLogger () {
203 // Variables declaration - do not modify//GEN-BEGIN:variables
204 private javax.swing.JMenu jMenu1;
205 private javax.swing.JMenu jMenu2;
206 private javax.swing.JMenuItem jMenuItem1;
207 private javax.swing.JMenuBar mainMenu;
208 private javax.swing.JScrollPane statusPane;
209 private javax.swing.JTextPane statusText;
210 // End of variables declaration//GEN-END:variables