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;
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);
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);
.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)
}// </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
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();
}
**/
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."));
}
}
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.
}
}
+ 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
*/