OSDN Git Service

ADD: SystemTray Support #13309
authorTakuya Ono <takuya-o@users.sourceforge.jp>
Sun, 17 Aug 2008 17:25:09 +0000 (17:25 +0000)
committerTakuya Ono <takuya-o@users.sourceforge.jp>
Sun, 17 Aug 2008 17:25:09 +0000 (17:25 +0000)
src/org/jent/checksmtp/ApplicationUI.form
src/org/jent/checksmtp/ApplicationUI.java
src/org/jent/checksmtp/Bundle_ja_JP.properties

index 572a7f9..977e265 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 
-<Form version="1.4" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+<Form version="1.4" maxVersion="1.4" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
   <Properties>
     <Property name="defaultCloseOperation" type="int" value="0"/>
     <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
@@ -32,7 +32,7 @@
           <Group type="102" attributes="0">
               <EmptySpace max="-2" attributes="0"/>
               <Component id="jButtonQuit" linkSize="1" min="-2" max="-2" attributes="0"/>
-              <EmptySpace pref="133" max="32767" attributes="0"/>
+              <EmptySpace pref="148" max="32767" attributes="0"/>
               <Component id="jButtonOK" linkSize="1" min="-2" max="-2" attributes="0"/>
               <EmptySpace max="-2" attributes="0"/>
               <Component id="jButtonCancel" linkSize="1" min="-2" max="-2" attributes="0"/>
                           <Group type="102" alignment="0" attributes="0">
                               <Component id="jLabel1" linkSize="2" min="-2" max="-2" attributes="0"/>
                               <EmptySpace min="-2" max="-2" attributes="0"/>
-                              <Component id="jTextFieldReceiverPort" pref="51" max="32767" attributes="0"/>
+                              <Component id="jTextFieldReceiverPort" pref="73" max="32767" attributes="0"/>
                               <EmptySpace max="-2" attributes="0"/>
                               <Component id="jCheckBoxEnableRemoteConnect" min="-2" pref="207" max="-2" attributes="0"/>
                           </Group>
                           <Group type="102" alignment="0" attributes="0">
                               <Component id="jLabel7" min="-2" max="-2" attributes="0"/>
                               <EmptySpace max="-2" attributes="0"/>
-                              <Component id="jTextFieldConfirmTimeout" pref="237" max="32767" attributes="0"/>
+                              <Component id="jTextFieldConfirmTimeout" pref="265" max="32767" attributes="0"/>
                               <EmptySpace max="-2" attributes="0"/>
                           </Group>
                           <Group type="102" alignment="1" attributes="0">
                               <Component id="jLabel2" linkSize="2" min="-2" max="-2" attributes="0"/>
                               <EmptySpace min="-2" max="-2" attributes="0"/>
-                              <Component id="jTextFieldServerHost" pref="143" max="32767" attributes="0"/>
+                              <Component id="jTextFieldServerHost" pref="155" max="32767" attributes="0"/>
                               <EmptySpace min="-2" max="-2" attributes="0"/>
                               <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
                               <EmptySpace min="-2" max="-2" attributes="0"/>
-                              <Component id="jTextFieldServerPort" pref="69" max="32767" attributes="0"/>
+                              <Component id="jTextFieldServerPort" pref="82" max="32767" attributes="0"/>
                               <EmptySpace min="-2" max="-2" attributes="0"/>
                           </Group>
                       </Group>
                           <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
                           <Component id="jTextFieldServerPort" alignment="3" min="-2" max="-2" attributes="0"/>
                       </Group>
-                      <EmptySpace pref="27" max="32767" attributes="0"/>
+                      <EmptySpace pref="31" max="32767" attributes="0"/>
                       <Group type="103" groupAlignment="3" attributes="0">
                           <Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
                           <Component id="jTextFieldConfirmTimeout" alignment="3" min="-2" max="-2" attributes="0"/>
                               </Group>
                               <EmptySpace max="-2" attributes="0"/>
                               <Group type="103" groupAlignment="0" attributes="0">
-                                  <Component id="jTextFieldAttribute" alignment="0" pref="288" max="32767" attributes="0"/>
-                                  <Component id="jTextFieldBaseDn" pref="288" max="32767" attributes="0"/>
+                                  <Component id="jTextFieldAttribute" alignment="0" pref="296" max="32767" attributes="0"/>
+                                  <Component id="jTextFieldBaseDn" pref="296" max="32767" attributes="0"/>
                                   <Group type="102" alignment="0" attributes="0">
-                                      <Component id="jTextFieldProviderUrl" pref="205" max="32767" attributes="0"/>
+                                      <Component id="jTextFieldProviderUrl" pref="222" max="32767" attributes="0"/>
                                       <EmptySpace max="-2" attributes="0"/>
                                       <Component id="jCheckBoxIsSjis" min="-2" max="-2" attributes="0"/>
                                   </Group>
                           <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
                           <Component id="jTextFieldAttribute" alignment="3" min="-2" max="-2" attributes="0"/>
                       </Group>
-                      <EmptySpace max="32767" attributes="0"/>
+                      <EmptySpace pref="17" max="32767" attributes="0"/>
                   </Group>
               </Group>
             </DimensionLayout>
                       </Group>
                       <EmptySpace max="-2" attributes="0"/>
                       <Component id="jLabelSfURL" min="-2" max="-2" attributes="0"/>
-                      <EmptySpace pref="57" max="32767" attributes="0"/>
+                      <EmptySpace pref="58" max="32767" attributes="0"/>
                   </Group>
               </Group>
             </DimensionLayout>
           <SubComponents>
             <Component class="javax.swing.JLabel" name="jLabelProgramName">
               <Properties>
-                <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
-                  <FontInfo relative="false">
-                    <Font name="Dialog" size="18" style="1"/>
-                  </FontInfo>
+                <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                  <Font name="Dialog" size="18" style="1"/>
                 </Property>
                 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
                   <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jLabelProgramName.text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
             </Component>
             <Component class="javax.swing.JLabel" name="jLabelProgramVersion">
               <Properties>
-                <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
-                  <FontInfo relative="false">
-                    <Font name="Dialog" size="18" style="1"/>
-                  </FontInfo>
+                <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                  <Font name="Dialog" size="18" style="1"/>
                 </Property>
                 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
                   <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jLabelProgramVersion.text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
             </Component>
             <Component class="javax.swing.JLabel" name="jLabelSfURL">
               <Properties>
-                <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
-                  <FontInfo relative="false">
-                    <Font name="Dialog" size="14" style="1"/>
-                  </FontInfo>
+                <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                  <Font name="Dialog" size="14" style="1"/>
                 </Property>
                 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
                   <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jLabelSfURL.text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
index a03c446..d5e1a21 100644 (file)
@@ -6,11 +6,16 @@
 
 package org.jent.checksmtp;
 
+import java.awt.AWTException;
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Image;
+import java.awt.MenuItem;
 import java.awt.Point;
+import java.awt.PopupMenu;
+import java.awt.SystemTray;
 import java.awt.Toolkit;
+import java.awt.TrayIcon;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import javax.swing.ImageIcon;
@@ -579,30 +584,28 @@ public class ApplicationUI extends javax.swing.JFrame {
   
   
   private boolean initSystemTray() {
-    boolean useSystemTray = false;
+    useSystemTray = false;
     try {
       Class.forName("java.awt.SystemTray"); // NOI18N
-      /* TODO: SystemTray suuport
-      SystemTray tray = SystemTray.getSystemTray();
-      if(tray.isSupported()){
+      /* SystemTray suuport */
+      final SystemTray tray = SystemTray.getSystemTray();
+      if(SystemTray.isSupported()){
         final PopupMenu popup = new PopupMenu();
-        TrayIcon trayIcon = new TrayIcon(loadIconImage(),
-                "mdc", popup);
+        final TrayIcon trayIcon = new TrayIcon(loadImageIcon(), 
+          java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle").getString("ApplicationUI.shortTitle"),
+          popup);
         trayIcon.setImageAutoSize(true);
        
-        MenuItem menuItemOpen = new MenuItem("Properties...");
+        MenuItem menuItemOpen = new MenuItem(java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle").getString("ApplicationUI.title"));
         menuItemOpen.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
-            setVisible(true);
-            if ( this.getExtendedState() == ICONIFIED ) {
-              this.setExtendedState(NORMAL);
-            }
+            deicoified();
           }
         });
-        MenuItem menuItemQuit = new MenuItem("Quit");
+        MenuItem menuItemQuit = new MenuItem(java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle").getString("ApplicationUI.jButtonQuit.text"));
         menuItemQuit.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
-            tray.remove(icon);
+            tray.remove(trayIcon);
             dispose();
             System.exit(0);
           }
@@ -610,9 +613,14 @@ public class ApplicationUI extends javax.swing.JFrame {
         popup.add(menuItemOpen);
         popup.add(menuItemQuit);
         tray.add(trayIcon);
+       
+        this.jButtonQuit.setVisible(false); //unvisible QUIT button.
         useSystemTray = true;
       }
-       */
+       /**/
+    } catch (AWTException ex) {
+      System.err.println("SystemTray initialize error.");
+      ex.printStackTrace();
     } catch (ClassNotFoundException ex) {
       // Do not support SystemTray on this VM.
     }
@@ -627,6 +635,14 @@ public class ApplicationUI extends javax.swing.JFrame {
     }
   }
   
+  private void deicoified() {
+    if ( useSystemTray ) {
+      this.setVisible(true);
+    } else {
+      this.setExtendedState(NORMAL);
+    } 
+  }
+  
   private Image loadImageIcon() {
     ImageIcon imageIcon = new ImageIcon( getClass()
     .getResource("images/mdc-icon16x16.png") // NOI18N
@@ -690,7 +706,6 @@ public class ApplicationUI extends javax.swing.JFrame {
         }
       }
     });
-    
     smtpClient = new SMTPclient();
   }
   private static SMTPclient smtpClient = null;
index 80358f8..6579686 100644 (file)
@@ -91,7 +91,7 @@ ApplicationUI.error.Fail_the_properties_file_save.=\u30D7\u30ED\u30D1\u30C6\u30A
 \r
 ApplicationUI.error.Out_of_range.=\u7BC4\u56F2\u304C\u4E0D\u6B63\u3067\u3059\u3002\r
 \r
-ApplicationUI.shortTitle=\u30E1\u30FC\u30EB\u9001\u4FE1\u5148\u78BA\u8A8D\r
+ApplicationUI.shortTitle=\u30E1\u30FC\u30EB\u9001\u4FE1\u5148\u78BA\u8A8D\u30D7\u30ED\u30B0\u30E9\u30E0\r
 \r
 ToListUI.error.Fail_the_properties_file_of_dialog_potition_save.=\u30C0\u30A4\u30A2\u30ED\u30B0\u306E\u4F4D\u7F6E\u306E\u4FDD\u5B58\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002\r
 \r