Takuya Ono
takuy****@users*****
2007年 8月 18日 (土) 04:12:21 JST
Index: BetaProject/src/org/jent/checksmtp/ApplicationUI.form diff -u BetaProject/src/org/jent/checksmtp/ApplicationUI.form:1.5 BetaProject/src/org/jent/checksmtp/ApplicationUI.form:1.6 --- BetaProject/src/org/jent/checksmtp/ApplicationUI.form:1.5 Fri Aug 17 01:52:08 2007 +++ BetaProject/src/org/jent/checksmtp/ApplicationUI.form Sat Aug 18 04:12:21 2007 @@ -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("{bundleNameSlashes}").getString("{key}")"/> </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"/> @@ -388,7 +391,7 @@ <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: BetaProject/src/org/jent/checksmtp/ApplicationUI.java diff -u BetaProject/src/org/jent/checksmtp/ApplicationUI.java:1.6 BetaProject/src/org/jent/checksmtp/ApplicationUI.java:1.7 --- BetaProject/src/org/jent/checksmtp/ApplicationUI.java:1.6 Fri Aug 17 01:52:08 2007 +++ BetaProject/src/org/jent/checksmtp/ApplicationUI.java Sat Aug 18 04:12:21 2007 @@ -8,10 +8,12 @@ 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 @@ 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 @@ 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 @@ .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 @@ }// </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 @@ 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 @@ **/ 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 @@ 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 @@ } } + 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 */