1 18 19 package sync4j.syncclient.demo; 20 21 import java.awt.BorderLayout ; 22 import java.awt.Button ; 23 import java.awt.Frame ; 24 import java.awt.GridLayout ; 25 import java.awt.Image ; 26 import java.awt.Label ; 27 import java.awt.Panel ; 28 import java.awt.Toolkit ; 29 30 import java.awt.event.ActionEvent ; 31 import java.awt.event.ActionListener ; 32 import java.awt.event.WindowEvent ; 33 import java.awt.event.WindowListener ; 34 35 42 43 public class CheckContactFields 44 extends Frame 45 implements 46 ActionListener , 47 WindowListener , 48 ConfigurationParameters { 49 50 52 54 57 private MainWindow mw = null ; 58 59 private ContactForm form = null ; 60 private Label lb1 = null ; 61 private Label lb2 = null ; 62 private Label lb3 = null ; 63 64 private Language ln = new Language() ; 65 66 68 public CheckContactFields(MainWindow mw, ContactForm form) { 69 70 super (); 71 setTitle (ln.getString("check_contact_fields")); 72 73 Button butOk = null ; 74 Panel textPanel = null ; 75 76 Image icon = null ; 77 78 icon = Toolkit.getDefaultToolkit().getImage(FRAME_ICONNAME); 79 80 setIconImage(icon); 81 82 this.mw = mw ; 83 this.form = form ; 84 85 setSize (300, 150) ; 86 setLocation (400, 200) ; 87 setLayout (new BorderLayout ()); 88 89 lb1 = new Label ("", Label.CENTER ) ; 90 lb2 = new Label ("", Label.CENTER ) ; 91 lb3 = new Label ("", Label.CENTER ) ; 92 93 butOk = new Button (ln.getString ("ok") ) ; 94 butOk.setActionCommand ("ok" ) ; 95 96 butOk.addActionListener(this ); 97 98 textPanel = new Panel (); 99 textPanel.setLayout(new GridLayout (3, 1) ); 100 textPanel.add(lb1); 101 textPanel.add(lb2); 102 textPanel.add(lb3); 103 104 add(textPanel, BorderLayout.CENTER ) ; 105 add(butOk , BorderLayout.SOUTH ) ; 106 107 addWindowListener(this); 108 109 } 110 111 public boolean areFieldsRight() { 112 113 String birthdayDate = null; 114 115 birthdayDate = form.getBirthdayDate(); 116 117 if (!FieldsHelper.checkDate(birthdayDate, FieldsHelper.DATE_FORMAT)) { 118 lb1.setText(ln.getString ("please_insert_a_valid_birthday_date")); 119 return false; 120 } 121 122 return true; 123 } 124 125 public void actionPerformed(ActionEvent evt) { 126 127 if (evt.getActionCommand().equals("ok")) { 128 mw.setEnabled(true); 129 hide(); 130 } 131 132 } 133 134 public void windowClosing(WindowEvent evt) { 135 mw.setEnabled(true); 136 hide(); 137 } 138 139 public void windowActivated (WindowEvent e) {} 140 141 public void windowClosed (WindowEvent e) {} 142 143 public void windowDeactivated (WindowEvent e) {} 144 145 public void windowDeiconified (WindowEvent e) {} 146 147 public void windowIconified (WindowEvent e) {} 148 149 public void windowOpened (WindowEvent e) {} 150 151 153 } | Popular Tags |