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 CheckCalendarFields 44 extends Frame 45 implements ActionListener , 46 WindowListener , 47 ConfigurationParameters { 48 49 51 53 56 private MainWindow mw = null ; 57 58 private CalendarForm form = null ; 59 private Label lb1 = null ; 60 private Label lb2 = null ; 61 private Label lb3 = null ; 62 63 private Language ln = new Language() ; 64 65 67 public CheckCalendarFields(MainWindow mw, CalendarForm form) { 68 69 super (); 70 setTitle (ln.getString("check_calendar_fields")); 71 72 Image icon = null ; 73 Button butOk = null ; 74 Panel textPanel = null ; 75 76 icon = Toolkit.getDefaultToolkit().getImage(FRAME_ICONNAME); 77 78 setIconImage(icon); 79 80 this.mw = mw ; 81 this.form = form ; 82 83 setSize (300, 150) ; 84 setLocation (400, 200) ; 85 setLayout (new BorderLayout ()); 86 87 lb1 = new Label ("", Label.CENTER ) ; 88 lb2 = new Label ("", Label.CENTER ) ; 89 lb3 = new Label ("", Label.CENTER ) ; 90 91 butOk = new Button (ln.getString ("ok") ) ; 92 butOk.setActionCommand ("ok" ) ; 93 94 butOk.addActionListener(this ); 95 96 textPanel = new Panel (); 97 textPanel.setLayout(new GridLayout (3, 1) ); 98 textPanel.add(lb1); 99 textPanel.add(lb2); 100 textPanel.add(lb3); 101 102 add(textPanel, BorderLayout.CENTER ) ; 103 add(butOk , BorderLayout.SOUTH ) ; 104 105 addWindowListener(this); 106 107 } 108 109 public boolean areFieldsRight() { 110 111 String startDate = null ; 112 String endDate = null ; 113 String startTime = null ; 114 String endTime = null ; 115 116 startDate = form.getStartDate() ; 117 endDate = form.getEndDate () ; 118 startTime = form.getStartTime() ; 119 endTime = form.getEndTime () ; 120 121 if (startDate == null || 122 startDate.length() == 0 || 123 startTime == null || 124 startTime.length() == 0 || 125 (!FieldsHelper.checkDate(startDate + " " + startTime + ":00", FieldsHelper.DATE_FORMAT_AND_TIME))) { 126 lb1.setText(ln.getString ("please_insert_valid_start_date_time")); 127 return false; 128 } 129 130 if (endDate == null || 131 endDate.length() == 0 || 132 endTime == null || 133 endTime.length() == 0 || 134 (!FieldsHelper.checkDate(endDate + " " + endTime + ":00", FieldsHelper.DATE_FORMAT_AND_TIME))) { 135 lb1.setText(ln.getString ("please_insert_valid_end_date_time")); 136 return false; 137 } 138 139 return true; 140 } 141 142 public void actionPerformed(ActionEvent evt) { 143 144 if (evt.getActionCommand().equals("ok")) { 145 mw.setEnabled(true); 146 hide(); 147 } 148 149 } 150 151 public void windowClosing(WindowEvent evt) { 152 mw.setEnabled(true); 153 hide(); 154 } 155 156 public void windowActivated (WindowEvent e) {} 157 158 public void windowClosed (WindowEvent e) {} 159 160 public void windowDeactivated (WindowEvent e) {} 161 162 public void windowDeiconified (WindowEvent e) {} 163 164 public void windowIconified (WindowEvent e) {} 165 166 public void windowOpened (WindowEvent e) {} 167 168 170 } | Popular Tags |