OSDN Git Service

Suuport: Windows icon.
authorTakuya Ono <takuya-o@users.sourceforge.jp>
Fri, 17 Aug 2007 19:15:14 +0000 (19:15 +0000)
committerTakuya Ono <takuya-o@users.sourceforge.jp>
Fri, 17 Aug 2007 19:15:14 +0000 (19:15 +0000)
Support: Error dialogs I18N.
BUGFIX: Title is hard code when iconize and deiconize.

deploy/mdc.zip
src/org/jent/checksmtp/ApplicationUI.form
src/org/jent/checksmtp/ApplicationUI.java

index a6c73af..dd2fb2e 100644 (file)
Binary files a/deploy/mdc.zip and b/deploy/mdc.zip differ
index 3e02273..5621344 100644 (file)
@@ -6,6 +6,9 @@
     <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
       <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.title" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
     </Property>
+    <Property name="iconImage" type="java.awt.Image" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+      <Connection code="loadImageIcon()" type="code"/>
+    </Property>
   </Properties>
   <SyntheticProperties>
     <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
                               <Component id="jLabelSfURL" min="-2" max="-2" attributes="0"/>
                           </Group>
                       </Group>
-                      <EmptySpace pref="35" max="32767" attributes="0"/>
+                      <EmptySpace max="32767" attributes="0"/>
                   </Group>
               </Group>
             </DimensionLayout>
index 265ff2c..1fbb024 100644 (file)
@@ -8,10 +8,12 @@ package org.jent.checksmtp;
 
 import java.awt.Color;
 import java.awt.Dimension;
+import java.awt.Image;
 import java.awt.Point;
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import javax.swing.ImageIcon;
 import javax.swing.InputVerifier;
 import javax.swing.JComponent;
 import javax.swing.JFrame;
@@ -66,7 +68,7 @@ public class ApplicationUI extends javax.swing.JFrame {
         jTextField.setBackground(Color.PINK);
         if ( portNumberOutOfRangeErrorDialog == null ) {
           portNumberOutOfRangeErrorDialog = 
-                  new MessageDialogUI("Port number is integer from 1 to 65535.",
+                  new MessageDialogUI(java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle").getString("ApplicationUI.Port_number_is_integer_from_1_to_65535."),
                   null, MessageDialogUI.WARNING_MODE);
         } else {
           portNumberOutOfRangeErrorDialog.setVisible(true);
@@ -115,6 +117,7 @@ public class ApplicationUI extends javax.swing.JFrame {
     setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
     java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle"); // NOI18N
     setTitle(bundle.getString("ApplicationUI.title")); // NOI18N
+    setIconImage(loadImageIcon());
     addWindowListener(new java.awt.event.WindowAdapter() {
       public void windowDeiconified(java.awt.event.WindowEvent evt) {
         formWindowDeiconified(evt);
@@ -297,7 +300,7 @@ public class ApplicationUI extends javax.swing.JFrame {
           .add(jPanelAboutLayout.createSequentialGroup()
             .add(55, 55, 55)
             .add(jLabelSfURL)))
-        .addContainerGap(35, Short.MAX_VALUE))
+        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
     );
     jPanelAboutLayout.setVerticalGroup(
       jPanelAboutLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@@ -368,12 +371,12 @@ public class ApplicationUI extends javax.swing.JFrame {
   }// </editor-fold>//GEN-END:initComponents
   
   private void formWindowDeiconified(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowDeiconified
-    setTitle("Mail Destination Confirm Properties");
+    setTitle(java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle").getString("ApplicationUI.title"));
     jButtonOK.requestFocusInWindow();
   }//GEN-LAST:event_formWindowDeiconified
   
   private void formWindowIconified(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowIconified
-    setTitle("mdc");
+    setTitle(java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle").getString("ApplicationUI.shortTitle"));
   }//GEN-LAST:event_formWindowIconified
   
   private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
@@ -428,8 +431,8 @@ public class ApplicationUI extends javax.swing.JFrame {
       
       smtpClient.configChangeNotify();
       if ( !ApplicationProperties.save() ) {
-        new MessageDialogUI("Fail the properties file save.", null,
-                MessageDialogUI.ERROR_MODE);
+        new MessageDialogUI(java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle").getString("ApplicationUI.error.Fail_the_properties_file_save."), null,
+          MessageDialogUI.ERROR_MODE);
       } else {
         iconified();
       }
@@ -444,7 +447,7 @@ public class ApplicationUI extends javax.swing.JFrame {
    **/
   private void checkPortRange(final int port) {
     if ( port <= 0 || port > 65535 ) {
-      throw new NumberFormatException("Out of range.");
+      throw new NumberFormatException(java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle").getString("ApplicationUI.error.Out_of_range."));
     }
   }
   
@@ -503,37 +506,37 @@ public class ApplicationUI extends javax.swing.JFrame {
   private boolean initSystemTray() {
     boolean useSystemTray = false;
     try {
-      Class.forName("java.awt.SystemTray");
+      Class.forName("java.awt.SystemTray"); // NOI18N
       /* TODO: SystemTray suuport
-      java.awt.SystemTray tray = java.awt.SystemTray.getSystemTray();
+      SystemTray tray = SystemTray.getSystemTray();
       if(tray.isSupported()){
-        java.awt.TrayIcon trayIcon = new java.awt.TrayIcon(
-                new javax.swing.ImageIcon(
-                SystemTrayTest.class.getResource("images/mdc.gif")).getImage());
+        final PopupMenu popup = new PopupMenu();
+        TrayIcon trayIcon = new TrayIcon(loadIconImage(),
+                "mdc", popup);
         trayIcon.setImageAutoSize(true);
-       
-        // create a action listener to listen for default action executed on the tray icon
-        ActionListener listener = new ActionListener() {
+        
+        MenuItem menuItemOpen = new MenuItem("Properties...");
+        menuItemOpen.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
-            // execute default action of the application
-            if ( e.paramString().equal("Quit")) {
-              System.exit(0);
-            } else {
-              setVisible(true);
-              if ( this.getExtendedState() == ICONIFIED ) {
-                this.setExtendedState(NORMAL);
-              }
+            setVisible(true);
+            if ( this.getExtendedState() == ICONIFIED ) {
+              this.setExtendedState(NORMAL);
             }
           }
-        };
-        java.awt.PopupMenu popup = new java.awt.PopupMenu();
-        popup.addActionListener(listener);
-        popup.add("Config");
-        popup.add("Quit");
-        trayIcon.setPopupMenu(popup);
+        });
+        MenuItem menuItemQuit = new MenuItem("Quit");
+        menuItemQuit.addActionListener(new ActionListener() {
+          public void actionPerformed(ActionEvent e) {
+            tray.remove(icon);
+            dispose();
+            System.exit(0);
+          }
+        });
+        popup.add(menuItemOpen);
+        popup.add(menuItemQuit);
         tray.add(trayIcon);
         useSystemTray = true;
-     }
+      }
        */
     } catch (ClassNotFoundException ex) {
       // Do not support SystemTray on this VM.
@@ -549,6 +552,14 @@ public class ApplicationUI extends javax.swing.JFrame {
     }
   }
   
+  private Image loadImageIcon() {
+    ImageIcon imageIcon = new ImageIcon( getClass()
+    .getResource("images/mdc-icon16x16.png") // NOI18N
+    ,java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle").getString("ApplicationUI.jLabelProgramName.text"));
+    
+    return imageIcon.getImage();
+  }
+  
   /**
    * @param args the command line arguments
    */