OSDN Git Service

MOD: Tempolary Bugfix for restore dialog potition. Bug# 10746
[mdc/BetaProject.git] / src / org / jent / checksmtp / ApplicationUI.java
1 /*
2  * ApplicationUI.java
3  *
4  * Created on 2007/07/21, 22:37
5  */
6
7 package org.jent.checksmtp;
8
9 import java.awt.Dimension;
10 import java.awt.Point;
11 import java.awt.Toolkit;
12 import java.awt.event.ActionEvent;
13 import java.awt.event.ActionListener;
14 import javax.swing.JFrame;
15
16 /**
17  *
18  * @author  Takuya Ono <takuya-o@users.sourceforge.jp>
19  */
20 public class ApplicationUI extends javax.swing.JFrame {
21   
22   /** Creates new form ApplicationUI */
23   public ApplicationUI() {
24     initComponents();
25     
26     resetDisplay();
27   }
28   
29   private void resetDisplay() {
30     jTextFieldReceiverPort.setText(Integer.toString(ApplicationProperties.getSmtpPort()));
31     jTextFieldServerHost.setText(ApplicationProperties.getSmtpServerHost());
32     jTextFieldServerPort.setText(Integer.toString(ApplicationProperties.getSmtpServerPort()));
33     jCheckBoxEnableRemoteConnect.setSelected(ApplicationProperties.getSmtpEnebleRemoteConnect());
34     
35     jCheckBoxLdap.setSelected(ApplicationProperties.getLdap());
36     jTextFieldProviderUrl.setText(ApplicationProperties.getLdapProviderURL());
37     jTextFieldBaseDn.setText(ApplicationProperties.getLdapRoot());
38     jTextFieldAttribute.setText(ApplicationProperties.getLdapAttributes());
39     jCheckBoxIsSjis.setSelected(ApplicationProperties.getLdapIsSjis());
40     
41   }
42   
43   
44   /** This method is called from within the constructor to
45    * initialize the form.
46    * WARNING: Do NOT modify this code. The content of this method is
47    * always regenerated by the Form Editor.
48    */
49   // <editor-fold defaultstate="collapsed" desc=" Generated Code">//GEN-BEGIN:initComponents
50   private void initComponents() {
51     jTabbedPane = new javax.swing.JTabbedPane();
52     jPanelMail = new javax.swing.JPanel();
53     jLabel1 = new javax.swing.JLabel();
54     jLabel2 = new javax.swing.JLabel();
55     jLabel3 = new javax.swing.JLabel();
56     jTextFieldReceiverPort = new javax.swing.JTextField();
57     jTextFieldServerHost = new javax.swing.JTextField();
58     jTextFieldServerPort = new javax.swing.JTextField();
59     jCheckBoxEnableRemoteConnect = new javax.swing.JCheckBox();
60     jPanelLDAP = new javax.swing.JPanel();
61     jCheckBoxLdap = new javax.swing.JCheckBox();
62     jLabel4 = new javax.swing.JLabel();
63     jLabel5 = new javax.swing.JLabel();
64     jLabel6 = new javax.swing.JLabel();
65     jTextFieldProviderUrl = new javax.swing.JTextField();
66     jTextFieldBaseDn = new javax.swing.JTextField();
67     jTextFieldAttribute = new javax.swing.JTextField();
68     jCheckBoxIsSjis = new javax.swing.JCheckBox();
69     jButtonOK = new javax.swing.JButton();
70     jButtonCancel = new javax.swing.JButton();
71     jButtonQuit = new javax.swing.JButton();
72
73     setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
74     setTitle("Mail Destination Confirm Properties");
75     addWindowListener(new java.awt.event.WindowAdapter() {
76       public void windowDeiconified(java.awt.event.WindowEvent evt) {
77         formWindowDeiconified(evt);
78       }
79       public void windowIconified(java.awt.event.WindowEvent evt) {
80         formWindowIconified(evt);
81       }
82     });
83
84     jLabel1.setText("Receiver Port:");
85
86     jLabel2.setText("Mail Server:");
87
88     jLabel3.setText("Port:");
89
90     jTextFieldReceiverPort.setText("8725");
91     jTextFieldReceiverPort.setToolTipText("Mail Destination Confirmer SMTP port number.");
92
93     jTextFieldServerHost.setText("mail");
94     jTextFieldServerHost.setToolTipText("Mail server host name or IP address.");
95
96     jTextFieldServerPort.setText("25");
97     jTextFieldServerPort.setToolTipText("Mail server port number.");
98
99     jCheckBoxEnableRemoteConnect.setText("Enable remote connect");
100     jCheckBoxEnableRemoteConnect.setToolTipText("Enable remote machine access this service. (Usually: disable)");
101     jCheckBoxEnableRemoteConnect.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
102     jCheckBoxEnableRemoteConnect.setMargin(new java.awt.Insets(0, 0, 0, 0));
103
104     org.jdesktop.layout.GroupLayout jPanelMailLayout = new org.jdesktop.layout.GroupLayout(jPanelMail);
105     jPanelMail.setLayout(jPanelMailLayout);
106     jPanelMailLayout.setHorizontalGroup(
107       jPanelMailLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
108       .add(jPanelMailLayout.createSequentialGroup()
109         .addContainerGap()
110         .add(jPanelMailLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
111           .add(jPanelMailLayout.createSequentialGroup()
112             .add(jLabel1)
113             .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
114             .add(jTextFieldReceiverPort, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
115             .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
116             .add(jCheckBoxEnableRemoteConnect))
117           .add(jPanelMailLayout.createSequentialGroup()
118             .add(jLabel2)
119             .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
120             .add(jTextFieldServerHost, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
121             .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
122             .add(jLabel3)
123             .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
124             .add(jTextFieldServerPort, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
125         .addContainerGap())
126     );
127
128     jPanelMailLayout.linkSize(new java.awt.Component[] {jLabel1, jLabel2}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
129
130     jPanelMailLayout.setVerticalGroup(
131       jPanelMailLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
132       .add(jPanelMailLayout.createSequentialGroup()
133         .addContainerGap()
134         .add(jPanelMailLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
135           .add(jLabel1)
136           .add(jCheckBoxEnableRemoteConnect)
137           .add(jTextFieldReceiverPort, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
138         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
139         .add(jPanelMailLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
140           .add(jLabel2)
141           .add(jLabel3)
142           .add(jTextFieldServerHost, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
143           .add(jTextFieldServerPort, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
144         .addContainerGap(74, Short.MAX_VALUE))
145     );
146     jTabbedPane.addTab("Mail", jPanelMail);
147
148     jCheckBoxLdap.setText("Enable LDAP search");
149     jCheckBoxLdap.setToolTipText("Enable LDAP configration.");
150     jCheckBoxLdap.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
151     jCheckBoxLdap.setMargin(new java.awt.Insets(0, 0, 0, 0));
152     jCheckBoxLdap.addChangeListener(new javax.swing.event.ChangeListener() {
153       public void stateChanged(javax.swing.event.ChangeEvent evt) {
154         jCheckBoxLdapStateChanged(evt);
155       }
156     });
157
158     jLabel4.setText("URL:");
159
160     jLabel5.setText("Root DN:");
161
162     jLabel6.setText("Attribute:");
163
164     jTextFieldProviderUrl.setText("ldap://localhost:389/");
165     jTextFieldProviderUrl.setToolTipText("LDAP server URL.");
166     jTextFieldProviderUrl.setEnabled(false);
167
168     jTextFieldBaseDn.setText("C=JP");
169     jTextFieldBaseDn.setToolTipText("LDAP search start DN.");
170     jTextFieldBaseDn.setEnabled(false);
171
172     jTextFieldAttribute.setText("cn");
173     jTextFieldAttribute.setToolTipText("Display Attribuite.  Example: cn title;lang-ja-jp");
174     jTextFieldAttribute.setEnabled(false);
175
176     jCheckBoxIsSjis.setText("Force SJIS");
177     jCheckBoxIsSjis.setToolTipText("Check this, when LDAP server use Shift JIS on network.");
178     jCheckBoxIsSjis.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
179     jCheckBoxIsSjis.setEnabled(false);
180     jCheckBoxIsSjis.setMargin(new java.awt.Insets(0, 0, 0, 0));
181
182     org.jdesktop.layout.GroupLayout jPanelLDAPLayout = new org.jdesktop.layout.GroupLayout(jPanelLDAP);
183     jPanelLDAP.setLayout(jPanelLDAPLayout);
184     jPanelLDAPLayout.setHorizontalGroup(
185       jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
186       .add(jPanelLDAPLayout.createSequentialGroup()
187         .add(jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
188           .add(jPanelLDAPLayout.createSequentialGroup()
189             .addContainerGap()
190             .add(jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
191               .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel6)
192               .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel5)
193               .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel4))
194             .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
195             .add(jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
196               .add(jTextFieldAttribute, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
197               .add(jTextFieldBaseDn, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
198               .add(jPanelLDAPLayout.createSequentialGroup()
199                 .add(jTextFieldProviderUrl, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
200                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
201                 .add(jCheckBoxIsSjis))))
202           .add(jPanelLDAPLayout.createSequentialGroup()
203             .add(12, 12, 12)
204             .add(jCheckBoxLdap)))
205         .addContainerGap())
206     );
207
208     jPanelLDAPLayout.linkSize(new java.awt.Component[] {jLabel4, jLabel5, jLabel6}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
209
210     jPanelLDAPLayout.setVerticalGroup(
211       jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
212       .add(jPanelLDAPLayout.createSequentialGroup()
213         .addContainerGap()
214         .add(jCheckBoxLdap)
215         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
216         .add(jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
217           .add(jLabel4)
218           .add(jTextFieldProviderUrl, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
219           .add(jCheckBoxIsSjis))
220         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
221         .add(jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
222           .add(jLabel5)
223           .add(jTextFieldBaseDn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
224         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
225         .add(jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
226           .add(jLabel6)
227           .add(jTextFieldAttribute, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
228         .addContainerGap(28, Short.MAX_VALUE))
229     );
230     jTabbedPane.addTab("LDAP", jPanelLDAP);
231
232     jButtonOK.setText("OK");
233     jButtonOK.addActionListener(new java.awt.event.ActionListener() {
234       public void actionPerformed(java.awt.event.ActionEvent evt) {
235         jButtonOKActionPerformed(evt);
236       }
237     });
238
239     jButtonCancel.setText("Cancel");
240     jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
241       public void actionPerformed(java.awt.event.ActionEvent evt) {
242         jButtonCancelActionPerformed(evt);
243       }
244     });
245
246     jButtonQuit.setText("Quit");
247     jButtonQuit.addActionListener(new java.awt.event.ActionListener() {
248       public void actionPerformed(java.awt.event.ActionEvent evt) {
249         jButtonQuitActionPerformed(evt);
250       }
251     });
252
253     org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
254     getContentPane().setLayout(layout);
255     layout.setHorizontalGroup(
256       layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
257       .add(jTabbedPane)
258       .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
259         .addContainerGap()
260         .add(jButtonQuit)
261         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 145, Short.MAX_VALUE)
262         .add(jButtonOK)
263         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
264         .add(jButtonCancel)
265         .addContainerGap())
266     );
267
268     layout.linkSize(new java.awt.Component[] {jButtonCancel, jButtonOK, jButtonQuit}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
269
270     layout.setVerticalGroup(
271       layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
272       .add(layout.createSequentialGroup()
273         .add(jTabbedPane)
274         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
275         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
276           .add(jButtonCancel)
277           .add(jButtonOK)
278           .add(jButtonQuit))
279         .addContainerGap())
280     );
281     pack();
282   }// </editor-fold>//GEN-END:initComponents
283
284   private void formWindowDeiconified(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowDeiconified
285     setTitle("Mail Destination Confirm Properties");
286   }//GEN-LAST:event_formWindowDeiconified
287
288   private void formWindowIconified(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowIconified
289     setTitle("mdc");
290   }//GEN-LAST:event_formWindowIconified
291     
292   private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
293     int port;
294     try {
295       port = Integer.parseInt(jTextFieldReceiverPort.getText());
296     } catch (NumberFormatException ex) {
297       ex.printStackTrace();
298       port = ApplicationProperties.getSmtpPort(); //last saved value.
299       jTextFieldReceiverPort.setText(Integer.toString(port));
300     }
301     String serverHost = jTextFieldServerHost.getText();
302     int serverPort;
303     try {
304       serverPort = Integer.parseInt(jTextFieldServerPort.getText());
305     } catch (NumberFormatException ex) {
306       ex.printStackTrace();
307       serverPort = ApplicationProperties.getSmtpServerPort(); //last saved value.
308       jTextFieldServerPort.setText(Integer.toString(serverPort));
309     }
310     boolean enableRemoteConnect = jCheckBoxEnableRemoteConnect.isSelected();
311     
312     boolean enableLdap = jCheckBoxLdap.isSelected();
313     String ldapUrl = jTextFieldProviderUrl.getText();
314     String rootDn = jTextFieldBaseDn.getText();
315     String attribute = jTextFieldAttribute.getText();
316     boolean isSjis = jCheckBoxIsSjis.isSelected();
317     
318     if ( port != ApplicationProperties.getSmtpPort()
319     || !serverHost.equals(ApplicationProperties.getSmtpServerHost())
320     || serverPort != ApplicationProperties.getSmtpServerPort()
321     || enableRemoteConnect != ApplicationProperties.getSmtpEnebleRemoteConnect()
322     
323     || enableLdap != ApplicationProperties.getLdap()
324     || !ldapUrl.equals(ApplicationProperties.getLdapProviderURL())
325     || !rootDn.equals(ApplicationProperties.getLdapRoot())
326     || !attribute.equals(ApplicationProperties.getLdapAttributes())
327     || isSjis != ApplicationProperties.getLdapIsSjis()
328     || isModifiedPotition()
329     ) {
330       // When modify data, save properries file.
331       ApplicationProperties.setSmtpPort(port);
332       ApplicationProperties.setSmtpServerHost(serverHost);
333       ApplicationProperties.setSmtpServerPort(serverPort);
334       ApplicationProperties.setSmtpEnableRemoteConnect(enableRemoteConnect);
335       
336       ApplicationProperties.setLdap(enableLdap);
337       ApplicationProperties.setLdapProviderURL(ldapUrl);
338       ApplicationProperties.setLdapRoot(rootDn);
339       ApplicationProperties.setLdapAttributes(attribute);
340       ApplicationProperties.setLdapIsSjis(isSjis);
341       
342       smtpClient.configChangeNotify();
343       if ( !ApplicationProperties.save() ) {
344         //TODO: Display Save error Dialog.
345       }
346     }
347     iconified();
348     
349   }//GEN-LAST:event_jButtonOKActionPerformed
350   
351   private void jButtonQuitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonQuitActionPerformed
352     System.exit(0);
353   }//GEN-LAST:event_jButtonQuitActionPerformed
354   
355   private void jCheckBoxLdapStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBoxLdapStateChanged
356 // TODO add your handling code here:
357     boolean check = jCheckBoxLdap.isSelected();
358     jTextFieldProviderUrl.setEnabled(check);
359     jTextFieldBaseDn.setEnabled(check);
360     jTextFieldAttribute.setEnabled(check);
361     jCheckBoxIsSjis.setEnabled(check);
362   }//GEN-LAST:event_jCheckBoxLdapStateChanged
363   
364   private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
365 // TODO add your handling code here:
366     //this.setVisible(false);
367     resetDisplay();
368     iconified();
369   }//GEN-LAST:event_jButtonCancelActionPerformed
370   
371   private boolean isModifiedPotition() {
372     int x = 0;
373     int y = 0;
374     if ( getExtendedState() == JFrame.NORMAL ) {
375       Point locationPoint = getLocationOnScreen(); //TODO: IllegalComponentStateException
376       x = locationPoint.x;
377       y = locationPoint.y;
378     } else {
379       //Unexpect logic. Because this method call from pushed "OK" button.
380       x = getX();
381       y = getY();
382     }  
383     int h = this.getHeight();
384     int w = this.getWidth();
385     boolean modified = false;
386     
387     if ( x != ApplicationProperties.getConfigDialogPosX()
388     || y != ApplicationProperties.getConfigDialogPosY()
389     || h != ApplicationProperties.getConfigDialogPosH()
390     || w != ApplicationProperties.getConfigDialogPosW()
391     ) {
392       modified = true;
393       ApplicationProperties.setConfigDialogPosX(x);
394       ApplicationProperties.setConfigDialogPosY(y);
395       ApplicationProperties.setConfigDialogPosH(h);
396       ApplicationProperties.setConfigDialogPosW(w);
397     }
398     return modified;
399   }
400   
401   
402   private boolean initSystemTray() {
403     boolean useSystemTray = false;
404     try {
405       Class.forName("java.awt.SystemTray");
406       /* TODO: SystemTray suuport
407       java.awt.SystemTray tray = java.awt.SystemTray.getSystemTray();
408       if(tray.isSupported()){
409         java.awt.TrayIcon trayIcon = new java.awt.TrayIcon(
410                 new javax.swing.ImageIcon(
411                 SystemTrayTest.class.getResource("images/mdc.gif")).getImage());
412         trayIcon.setImageAutoSize(true);
413        
414         // create a action listener to listen for default action executed on the tray icon
415         ActionListener listener = new ActionListener() {
416           public void actionPerformed(ActionEvent e) {
417             // execute default action of the application
418             if ( e.paramString().equal("Quit")) {
419               System.exit(0);
420             } else {
421               setVisible(true);
422               if ( this.getExtendedState() == ICONIFIED ) {
423                 this.setExtendedState(NORMAL);
424               }
425             }
426           }
427         };
428         java.awt.PopupMenu popup = new java.awt.PopupMenu();
429         popup.addActionListener(listener);
430         popup.add("Config");
431         popup.add("Quit");
432         trayIcon.setPopupMenu(popup);
433         tray.add(trayIcon);
434         useSystemTray = true;
435      }
436     */
437   } catch (ClassNotFoundException ex) {
438     // Do not support SystemTray on this VM.
439   }
440   return useSystemTray;
441 }
442
443 private void iconified() {
444   if ( useSystemTray ) {
445     this.setVisible(false);
446   } else {
447     this.setExtendedState(ICONIFIED);
448   }
449 }
450
451 /**
452  * @param args the command line arguments
453  */
454 public static void main(String args[]) {
455     /* TKYN OLD
456     try {
457       UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
458     } catch (Exception e) {
459       e.printStackTrace();
460     }
461      */
462   
463   //TKYN ORIGNAL BLOCK
464   java.awt.EventQueue.invokeLater(new Runnable() {
465     public void run() {
466       Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
467       ApplicationUI applicationUI = new ApplicationUI();
468       applicationUI.setVisible(true);
469       
470       applicationUI.useSystemTray = applicationUI.initSystemTray();
471       
472       //If exsist configuration file, iconise at start up.
473       if ( ApplicationProperties.isFileLoaded() ) {
474         int x = ApplicationProperties.getConfigDialogPosX();
475         int y = ApplicationProperties.getConfigDialogPosY();
476         int w = ApplicationProperties.getConfigDialogPosW();
477         int h = ApplicationProperties.getConfigDialogPosH();
478         
479         if ( x > screenSize.width ) {
480           x = screenSize.width - w;
481           if ( x < 0 ) { x = 0; };
482         }
483         if ( y > screenSize.height ) {
484           y = screenSize.height - h;
485           if ( y < 0 ) { y = 0; };
486         }
487         applicationUI.setBounds(x, y, w, h);
488         applicationUI.iconified();
489       } else {
490         //No Configuration file.
491         Dimension frameSize =  ApplicationProperties.getConfigurationDialogSize();
492         if (frameSize.height > screenSize.height) {
493           frameSize.height = screenSize.height;
494         }
495         if (frameSize.width > screenSize.width) {
496           frameSize.width = screenSize.width;
497         }
498         
499         applicationUI.setBounds(
500                 (screenSize.width - frameSize.width) / 2,
501                 (screenSize.height - frameSize.height) / 2,
502                 frameSize.width, frameSize.height );
503       }
504     }
505   });
506   
507   smtpClient = new SMTPclient();
508 }
509 private static SMTPclient smtpClient = null;
510 private boolean useSystemTray = false;
511
512   // Variables declaration - do not modify//GEN-BEGIN:variables
513   private javax.swing.JButton jButtonCancel;
514   private javax.swing.JButton jButtonOK;
515   private javax.swing.JButton jButtonQuit;
516   private javax.swing.JCheckBox jCheckBoxEnableRemoteConnect;
517   private javax.swing.JCheckBox jCheckBoxIsSjis;
518   private javax.swing.JCheckBox jCheckBoxLdap;
519   private javax.swing.JLabel jLabel1;
520   private javax.swing.JLabel jLabel2;
521   private javax.swing.JLabel jLabel3;
522   private javax.swing.JLabel jLabel4;
523   private javax.swing.JLabel jLabel5;
524   private javax.swing.JLabel jLabel6;
525   private javax.swing.JPanel jPanelLDAP;
526   private javax.swing.JPanel jPanelMail;
527   private javax.swing.JTabbedPane jTabbedPane;
528   private javax.swing.JTextField jTextFieldAttribute;
529   private javax.swing.JTextField jTextFieldBaseDn;
530   private javax.swing.JTextField jTextFieldProviderUrl;
531   private javax.swing.JTextField jTextFieldReceiverPort;
532   private javax.swing.JTextField jTextFieldServerHost;
533   private javax.swing.JTextField jTextFieldServerPort;
534   // End of variables declaration//GEN-END:variables
535   
536 }