KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > demo > CheckContactFields


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package sync4j.syncclient.demo;
20
21 import java.awt.BorderLayout JavaDoc;
22 import java.awt.Button JavaDoc;
23 import java.awt.Frame JavaDoc;
24 import java.awt.GridLayout JavaDoc;
25 import java.awt.Image JavaDoc;
26 import java.awt.Label JavaDoc;
27 import java.awt.Panel JavaDoc;
28 import java.awt.Toolkit JavaDoc;
29
30 import java.awt.event.ActionEvent JavaDoc;
31 import java.awt.event.ActionListener JavaDoc;
32 import java.awt.event.WindowEvent JavaDoc;
33 import java.awt.event.WindowListener JavaDoc;
34
35 /**
36  * The new contact insertion panel.
37  *
38  * @author Fabio Maggi @ Funambol
39  * @author Marco Magistrali @ Funambol
40  * @version $Id: CheckContactFields.java,v 1.5 2005/01/19 11:01:11 fabius Exp $
41  */

42
43 public class CheckContactFields
44 extends Frame JavaDoc
45 implements
46 ActionListener JavaDoc,
47 WindowListener JavaDoc,
48 ConfigurationParameters {
49
50     //--------------------------------------------------------------- Constants
51

52     //--------------------------------------------------------------- Private data
53

54     /**
55      * The window containing this panel
56      */

57     private MainWindow mw = null ;
58
59     private ContactForm form = null ;
60     private Label JavaDoc lb1 = null ;
61     private Label JavaDoc lb2 = null ;
62     private Label JavaDoc lb3 = null ;
63
64     private Language ln = new Language() ;
65
66     //--------------------------------------------------------------- Public methods
67

68     public CheckContactFields(MainWindow mw, ContactForm form) {
69
70         super ();
71         setTitle (ln.getString("check_contact_fields"));
72
73         Button JavaDoc butOk = null ;
74         Panel JavaDoc textPanel = null ;
75
76         Image JavaDoc 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 JavaDoc());
88
89         lb1 = new Label JavaDoc("", Label.CENTER ) ;
90         lb2 = new Label JavaDoc("", Label.CENTER ) ;
91         lb3 = new Label JavaDoc("", Label.CENTER ) ;
92
93         butOk = new Button JavaDoc (ln.getString ("ok") ) ;
94         butOk.setActionCommand ("ok" ) ;
95
96         butOk.addActionListener(this );
97
98         textPanel = new Panel JavaDoc();
99         textPanel.setLayout(new GridLayout JavaDoc(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 JavaDoc 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 JavaDoc evt) {
126
127         if (evt.getActionCommand().equals("ok")) {
128                mw.setEnabled(true);
129                hide();
130         }
131
132     }
133
134     public void windowClosing(WindowEvent JavaDoc evt) {
135         mw.setEnabled(true);
136         hide();
137     }
138
139     public void windowActivated (WindowEvent JavaDoc e) {}
140
141     public void windowClosed (WindowEvent JavaDoc e) {}
142
143     public void windowDeactivated (WindowEvent JavaDoc e) {}
144
145     public void windowDeiconified (WindowEvent JavaDoc e) {}
146
147     public void windowIconified (WindowEvent JavaDoc e) {}
148
149     public void windowOpened (WindowEvent JavaDoc e) {}
150
151     //--------------------------------------------------------------- Private methods
152

153 }
Popular Tags