1 18 19 package sync4j.syncclient.demo; 20 21 import java.awt.BorderLayout ; 22 import java.awt.Button ; 23 import java.awt.GridLayout ; 24 import java.awt.Label ; 25 import java.awt.Panel ; 26 import java.awt.event.ActionEvent ; 27 import java.awt.event.ActionListener ; 28 29 35 public class CalendarNew 36 extends Panel 37 implements ActionListener , ConfigurationParameters { 38 39 41 43 private MainWindow mw = null ; 47 48 private CalendarForm form = null ; 49 private CheckCalendarFields cfields = null ; 50 51 private Language ln = new Language() ; 52 53 55 60 public CalendarNew(MainWindow mw) { 61 62 Label title = null ; 63 Button butOk = null ; 64 Button butCancel = null ; 65 Panel buttonPanel = null ; 66 67 this.mw = mw; 68 69 setLayout(new BorderLayout ()); 70 title = new Label (ln.getString ("new_calendar")); 71 72 form = new CalendarForm(mw); 73 74 butOk = new Button (ln.getString ("ok") ) ; 75 butOk.setActionCommand ("ok" ) ; 76 butOk.addActionListener (this ) ; 77 78 butCancel = new Button (ln.getString ("cancel") ) ; 79 butCancel.setActionCommand ("cancel" ) ; 80 butCancel.addActionListener (this ) ; 81 82 buttonPanel = new Panel (); 83 buttonPanel.setLayout (new GridLayout (1, 2)); 84 buttonPanel.add (butOk ) ; 85 buttonPanel.add (butCancel ) ; 86 87 add(title , BorderLayout.NORTH ) ; 88 add(form , BorderLayout.CENTER ) ; 89 add(buttonPanel , BorderLayout.SOUTH ) ; 90 } 91 92 97 public void actionPerformed(ActionEvent evt) { 98 99 if (evt.getActionCommand().equals("ok")) { 100 101 cfields = new CheckCalendarFields(mw, form); 102 if (!cfields.areFieldsRight()) { 103 cfields.show(); 104 mw.setEnabled(false); 105 } 106 else { 107 saveCalendar(); 108 } 109 110 } else if (evt.getActionCommand().equals("cancel")) { 111 mw.show(KEY_CALENDARLIST); 112 } 113 } 114 115 117 121 protected void blankFields() { 122 form.blankFields(); 123 } 124 125 127 130 private void saveCalendar() { 131 mw.writeNewCalendar(form.getFields()); 132 mw.show(KEY_CALENDARLIST); 133 } 134 135 136 } | Popular Tags |