]> andersk Git - moira.git/blob - clients/regapplet/regapplet/Regapplet.java
If applet is using port 443 if we're not in standalone mode, don't
[moira.git] / clients / regapplet / regapplet / Regapplet.java
1 //Title:      Athena Registration Applet
2 //Version:    
3 //Copyright:  Copyright (c) 1997
4 //Author:     Jeffrey I. Schiller
5 //Company:    MIT
6 //Description:Applet to facilitate new user Athena account registration
7 package regapplet;
8
9 import java.awt.*;
10 import java.io.OutputStream;
11 import java.io.BufferedOutputStream;
12 import java.io.BufferedInputStream;
13 import java.io.InputStream;
14 import java.io.IOException;
15 import java.awt.event.*;
16 import java.applet.*;
17 import mit.cipher.MITCipherException;
18 import mit.cipher.Encap;
19
20 // For sockets...
21
22 import java.net.Socket;
23 import java.net.ServerSocket;   // For debugging we are a server
24 import java.util.ResourceBundle;
25
26 public class Regapplet extends Applet {
27   //  ResourceBundle res = ResourceBundle.getBundle("regapplet.Res");
28   static final boolean doRules = true;
29   mybundle res = new mybundle();
30   boolean isStandalone = false;
31   CardLayout cardLayout1 = new CardLayout();
32   Panel NamePanel = new Panel();
33   Label titlelabel = new Label();
34   Label FirstNameLabel = new Label();
35   Label LastNameLabel = new Label();
36   Label MiddleNameLabel = new Label();
37   Label MITIDlabel = new Label();
38   TextField FirstName = new TextField("", 30);
39   TextField LastName = new TextField("", 30);
40   TextField MiddleName = new TextField("", 1);
41   TextField MITID = new TextField("", 20); // Should only be 9, but Netscape loses
42   Panel WordPanel = new Panel();
43   TextBlock WordInstructions = new TextBlock(600,40);
44   Button NameContButton = new Button();
45   Button NameCancelButton = new Button();
46   Button WordCancelButton = new Button();
47   Button LoginCancelButton = new Button();
48   Button PasswordCancelButton = new Button();
49   Label WordLabel = new Label();
50   TextField Word1 = new TextField("", 6);
51   TextField Word2 = new TextField("", 6);
52   TextField Word3 = new TextField("", 6);
53   TextField Word4 = new TextField("", 6);
54   TextField Word5 = new TextField("", 6);
55   TextField Word6 = new TextField("", 6);
56   Button WordContButton = new Button();
57   GridBagLayout gridBagLayout1 = new GridBagLayout();
58   GridBagLayout gridBagLayout2 = new GridBagLayout();
59   GridLayout gridLayout1 = new GridLayout(3, 1);
60   Button ExitButton = new Button();
61
62   // PIN Panel.
63   Panel PinPanel = new Panel();
64   TextBlock PinInstructions = new TextBlock(600,40);
65   Button PinCancelButton = new Button();
66   Button PinContButton = new Button();
67   TextField Pin = new TextField("", 8);
68   Label PinLabel = new Label();
69   GridBagLayout gridBagLayout7 = new GridBagLayout();
70
71   // login confirmation panel.
72   Panel LoginConfirmPanel = new Panel();
73   TextBlock LoginConfirmInstructions = new TextBlock(600,40);
74   Button LoginConfirmCancelButton = new Button();
75   Button LoginConfirmContButton = new Button();
76   GridBagLayout gridBagLayout8 = new GridBagLayout();
77
78   Panel LoginPanel = new Panel();
79   TextBlock LoginNameBanner = new TextBlock(600,30);
80   Label LoginNameLabel = new Label();
81   TextField LoginName = new TextField("", 15);
82   Button LoginContButton = new Button();
83   GridBagLayout gridBagLayout3 = new GridBagLayout();
84   Panel PasswordPanel = new Panel();
85   TextBlock PasswordBanner = new TextBlock(600,30);
86   GridBagLayout gridBagLayout4 = new GridBagLayout();
87   Label PasswordLabel1 = new Label();
88   TextField Password1 = new TextField("", 10);
89   Label PasswordLabel2 = new Label();
90   TextField Password2 = new TextField("", 10);
91   Button PasswordContButton = new Button();
92   Panel GreetingPanel = new Panel();
93   Button GreetingButton = new Button();
94   Label Greeting1 = new Label();
95   GridBagLayout gridBagLayout5 = new GridBagLayout();
96   MessagePanel mp = new MessagePanel(this);
97   BalePanel bp = new BalePanel(this);
98   GridBagLayout gridBagLayout6 = new GridBagLayout();
99   Panel RulePanel = new Panel();
100   Button RuleButton = new Button();
101   TextArea Rules = new TextArea(res.getString("rules"), 20, 72);
102   Label RuleBanner = new Label();
103   public Worker worker = null;
104   public Thread workthread = null;
105   public String guesslogin = "";
106   public String chosenlogin = "";
107  
108   //Get a parameter value
109   public String getParameter(String key, String def) {
110     return isStandalone ? System.getProperty(key, def) :
111       (getParameter(key) != null ? getParameter(key) : def);
112   }
113
114   //Construct the applet
115   public Regapplet() {
116   }
117
118   //Initialize the applet
119   public void init() {
120     try { jbInit(); } catch (Exception e) { e.printStackTrace(); }
121     try {
122       this.add("MessagePanel", mp);
123       this.add("BalePanel", bp);
124     } catch (Exception e) {
125       e.printStackTrace();
126     }
127     this.setBackground(Color.white);
128   }
129
130   //Component initialization
131   public void jbInit() throws Exception{
132       //    this.resize(new Dimension(600, 600));
133     titlelabel.setForeground(Color.red);
134     titlelabel.setFont(new Font("Helvetica", 1, 18));
135     titlelabel.setText(res.getString("welcome"));
136     titlelabel.setBackground(Color.white);
137     FirstNameLabel.setText("Please Enter your First Name");
138     FirstNameLabel.setBackground(Color.white);
139     LastNameLabel.setText("Please Enter your Last Name");
140     LastNameLabel.setBackground(Color.white);
141     MiddleNameLabel.setText("Please Enter your Middle Initial");
142     MiddleNameLabel.setBackground(Color.white);
143     MITIDlabel.setText("Please enter your MIT ID Number");
144     MITIDlabel.setBackground(Color.white);
145     WordInstructions.setText(res.getString("getw"));
146     NameContButton.setLabel("Continue");
147     NameContButton.setBackground(Color.white);
148     NameCancelButton.setLabel("Cancel");
149     NameCancelButton.setBackground(Color.white);
150     WordLabel.setText("Key Words:");
151     WordLabel.setBackground(Color.white);
152     WordContButton.setLabel("Continue");
153     WordContButton.setBackground(Color.white);
154     WordCancelButton.setLabel("Cancel");
155     WordCancelButton.setBackground(Color.white);
156
157     // PIN initialization.
158     PinInstructions.setText(res.getString("geti"));
159     PinLabel.setText("PIN:");
160     PinLabel.setBackground(Color.white);
161     PinContButton.setLabel("Continue");
162     PinContButton.setBackground(Color.white);
163     PinCancelButton.setLabel("Cancel");
164     PinCancelButton.setBackground(Color.white);
165     Pin.setEchoCharacter('*');
166
167     // login confirmation initialization.
168     LoginConfirmContButton.setLabel("Continue");
169     LoginConfirmContButton.setBackground(Color.white);
170     LoginConfirmCancelButton.setLabel("Cancel");
171     LoginConfirmCancelButton.setBackground(Color.white);
172
173     ExitButton.setLabel("Exit");
174     ExitButton.setBackground(Color.white);
175     LoginNameLabel.setText("Chosen Login Name: ");
176     LoginNameLabel.setBackground(Color.white);
177     LoginContButton.setLabel("Continue");
178     LoginContButton.setBackground(Color.white);
179     LoginCancelButton.setLabel("Cancel");
180     LoginCancelButton.setBackground(Color.white);
181     PasswordBanner.setText(res.getString("getp"));
182     PasswordLabel1.setText("Please choose and enter a password");
183     PasswordLabel1.setBackground(Color.white);
184     Password1.setEchoCharacter('*');
185     PasswordLabel2.setText("Please enter your password again");
186     PasswordLabel2.setBackground(Color.white);
187     Password2.setEchoCharacter('*');
188     PasswordContButton.setLabel("Continue");
189     PasswordContButton.setBackground(Color.white);
190     PasswordCancelButton.setLabel("Cancel");
191     PasswordCancelButton.setBackground(Color.white);
192     PasswordPanel.setLayout(gridBagLayout4);
193     LoginPanel.setLayout(gridBagLayout3);
194     WordPanel.setLayout(gridBagLayout1);
195     NamePanel.setLayout(gridBagLayout2);
196     this.setLayout(cardLayout1);
197     this.add("NamePanel", NamePanel);
198     NamePanel.add(titlelabel);
199     gridBagLayout2.setConstraints(titlelabel, new GridBagConstraints2(0, 0, 5, 1, 0.0, 0.0
200             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(31, 24, 10, 24), 0, 0));
201     NamePanel.add(FirstNameLabel);
202     gridBagLayout2.setConstraints(FirstNameLabel, new GridBagConstraints2(0, 1, 1, 1, 0.0, 0.0
203             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 0, 0), 0, 0));
204     NamePanel.add(MiddleNameLabel);
205     gridBagLayout2.setConstraints(MiddleNameLabel, new GridBagConstraints2(0, 2, 1, 1, 0.0, 0.0
206             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 0, 0), 0, 0));
207     NamePanel.add(LastNameLabel);
208     gridBagLayout2.setConstraints(LastNameLabel, new GridBagConstraints2(0, 3, 1, 1, 0.0, 0.0
209             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 0, 0), 0, 0));
210     NamePanel.add(MITIDlabel);
211     gridBagLayout2.setConstraints(MITIDlabel, new GridBagConstraints2(0, 4, 1, 1, 0.0, 0.0
212             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 0, 0), 0, 0));
213     NamePanel.add(FirstName);
214     gridBagLayout2.setConstraints(FirstName, new GridBagConstraints2(2, 1, 3, 1, 0.0, 0.0
215             ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 10), 0, 0));
216     NamePanel.add(MiddleName);
217     gridBagLayout2.setConstraints(MiddleName, new GridBagConstraints2(2, 2, 3, 1, 0.0, 0.0
218             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 10), 0, 0));
219     NamePanel.add(LastName);
220     gridBagLayout2.setConstraints(LastName, new GridBagConstraints2(2, 3, 3, 1, 0.0, 0.0
221             ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 10), 0, 0));
222     NamePanel.add(MITID);
223     gridBagLayout2.setConstraints(MITID, new GridBagConstraints2(2, 4, 3, 1, 0.0, 0.0
224             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 10), 0, 0));
225     NamePanel.add(NameContButton);
226     gridBagLayout2.setConstraints(NameContButton, new GridBagConstraints2(2, 5, 1, 1, 0.0, 1.0
227             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(20, 10, 10, 10), 0, 0));
228     NamePanel.add(NameCancelButton);
229     gridBagLayout2.setConstraints(NameCancelButton, new GridBagConstraints2(4, 5, 1, 1, 0.0, 1.0
230             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(20, 10, 10, 10), 0, 0));
231
232     if (isStandalone) {
233       GreetingPanel.add(ExitButton);
234       gridBagLayout5.setConstraints(ExitButton, new GridBagConstraints2(5, 5, 1, 1, 0.0, 1.0
235             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(20, 10, 10, 10), 0, 0));
236     }
237     this.add("WordPanel", WordPanel);
238     WordPanel.add(WordInstructions);
239     gridBagLayout1.setConstraints(WordInstructions, new GridBagConstraints2(0, 0, 7, 1, 0.0, 0.0
240             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(19, 31, 10, 31), 0, 0));
241     WordPanel.add(WordLabel);
242     gridBagLayout1.setConstraints(WordLabel, new GridBagConstraints2(0, 1, 1, 2, 0.0, 0.0
243             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0));
244     WordPanel.add(Word1);
245     gridBagLayout1.setConstraints(Word1, new GridBagConstraints2(1, 1, 1, 1, 0.0, 0.0
246             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0));
247     WordPanel.add(Word2);
248     gridBagLayout1.setConstraints(Word2, new GridBagConstraints2(2, 1, 1, 1, 0.0, 0.0
249             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0));
250     WordPanel.add(Word3);
251     gridBagLayout1.setConstraints(Word3, new GridBagConstraints2(3, 1, 1, 1, 0.0, 0.0
252             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0));
253     WordPanel.add(Word4);
254     gridBagLayout1.setConstraints(Word4, new GridBagConstraints2(1, 2, 1, 1, 0.0, 0.0
255             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0));
256     WordPanel.add(Word5);
257     gridBagLayout1.setConstraints(Word5, new GridBagConstraints2(2, 2, 1, 1, 0.0, 0.0
258             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0));
259     WordPanel.add(Word6);
260     gridBagLayout1.setConstraints(Word6, new GridBagConstraints2(3, 2, 1, 1, 0.0, 0.0
261             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0));
262     WordPanel.add(WordContButton);
263     gridBagLayout1.setConstraints(WordContButton, new GridBagConstraints2(2, 3, 2, 2, 0.0, 1.0
264             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 0, 10, 0), 0, 0));
265     WordPanel.add(WordCancelButton);
266     gridBagLayout1.setConstraints(WordCancelButton, new GridBagConstraints2(4, 3, 2, 2, 0.0, 1.0
267             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 0, 10, 0), 0, 0));
268     this.add("LoginConfirmPanel", LoginConfirmPanel);
269     LoginConfirmPanel.add(LoginConfirmInstructions);
270     gridBagLayout8.setConstraints(LoginConfirmInstructions, new GridBagConstraints2(0, 0, 3, 3, 0.0, 0.0
271             ,GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0));
272     LoginConfirmPanel.add(LoginConfirmContButton);
273     gridBagLayout8.setConstraints(LoginConfirmContButton, new GridBagConstraints2(1, 4, 1, 1, 0.0, 1.0
274                   ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 0, 20, 0), 0, 0));
275     LoginConfirmPanel.add(LoginConfirmCancelButton);
276     gridBagLayout8.setConstraints(LoginConfirmCancelButton, new GridBagConstraints2(2, 4, 1, 1, 0.0, 1.0
277                   ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 0, 20, 0), 0, 0));
278     this.add("PinPanel", PinPanel);
279     PinPanel.add(PinInstructions);
280     gridBagLayout7.setConstraints(PinInstructions, new GridBagConstraints2(0, 0, 4, 1, 0.0, 0.0
281             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(20, 10, 10, 20), 0, 0));
282     PinPanel.add(PinLabel);
283     gridBagLayout7.setConstraints(PinLabel, new GridBagConstraints2(0, 1, 1, 1, 0.0, 0.0
284             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(20, 10, 0, 0), 0, 0));
285     PinPanel.add(Pin);
286     gridBagLayout7.setConstraints(Pin, new GridBagConstraints2(1, 1, 1, 1, 0.0, 0.0
287             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(20, 0, 0, 10), 2, 0));
288     PinPanel.add(PinContButton);
289     gridBagLayout7.setConstraints(PinContButton, new GridBagConstraints2(1, 2, 1, 1, 0.0, 1.0
290             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
291     PinPanel.add(PinCancelButton);
292     gridBagLayout7.setConstraints(PinCancelButton, new GridBagConstraints2(3, 2, 1, 1, 0.0, 1.0
293             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
294     this.add("LoginPanel", LoginPanel);
295     LoginPanel.add(LoginNameBanner);
296     gridBagLayout3.setConstraints(LoginNameBanner, new GridBagConstraints2(0, 0, 4, 1, 0.0, 0.0
297             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(20, 10, 10, 20), 0, 0));
298     LoginPanel.add(LoginNameLabel);
299     gridBagLayout3.setConstraints(LoginNameLabel, new GridBagConstraints2(0, 1, 1, 1, 0.0, 0.0
300             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(20, 10, 0, 0), 0, 0));
301     LoginPanel.add(LoginName);
302     gridBagLayout3.setConstraints(LoginName, new GridBagConstraints2(1, 1, 1, 1, 0.0, 0.0
303             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(20, 0, 0, 10), 2, 0));
304     LoginPanel.add(LoginContButton);
305     gridBagLayout3.setConstraints(LoginContButton, new GridBagConstraints2(1, 2, 1, 1, 0.0, 1.0
306             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
307     LoginPanel.add(LoginCancelButton);
308     gridBagLayout3.setConstraints(LoginCancelButton, new GridBagConstraints2(3, 2, 1, 1, 0.0, 1.0
309             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
310     this.add("PasswordPanel", PasswordPanel);
311     PasswordPanel.add(PasswordBanner);
312     gridBagLayout4.setConstraints(PasswordBanner, new GridBagConstraints2(0, 0, 6, 1, 0.0, 0.0
313             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(20, 10, 10, 20), 0, 0));
314     PasswordPanel.add(PasswordLabel1);
315     gridBagLayout4.setConstraints(PasswordLabel1, new GridBagConstraints2(0, 1, 3, 1, 0.0, 0.0
316             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(20, 10, 0, 0), 0, 0));
317     PasswordPanel.add(Password1);
318     gridBagLayout4.setConstraints(Password1, new GridBagConstraints2(3, 1, 3, 1, 0.0, 0.0
319             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(20, 10, 0, 10), 0, 0));
320     PasswordPanel.add(PasswordLabel2);
321     gridBagLayout4.setConstraints(PasswordLabel2, new GridBagConstraints2(0, 2, 3, 1, 0.0, 0.0
322             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 0, 0), 0, 0));
323     PasswordPanel.add(Password2);
324     gridBagLayout4.setConstraints(Password2, new GridBagConstraints2(3, 2, 3, 1, 0.0, 0.0
325             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 0, 10), 0, 0));
326     PasswordPanel.add(PasswordContButton);
327     gridBagLayout4.setConstraints(PasswordContButton, new GridBagConstraints2(3, 4, 1, 1, 0.0, 1.0
328             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0));
329     PasswordPanel.add(PasswordCancelButton);
330     gridBagLayout4.setConstraints(PasswordCancelButton, new GridBagConstraints2(5, 4, 1, 1, 0.0, 1.0
331             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0));
332     GreetingPanel.setLayout(gridBagLayout5);
333     GreetingButton.setLabel("Start!");
334     GreetingButton.setBackground(Color.white);
335     Greeting1.setForeground(Color.red);
336     Greeting1.setFont(new Font("Dialog", 1, 18));
337     Greeting1.setText(res.getString("welcome"));
338     Greeting1.setBackground(Color.white);
339     this.add("GreetingPanel", GreetingPanel);
340     GreetingPanel.add(GreetingButton);
341     gridBagLayout5.setConstraints(GreetingButton, new GridBagConstraints2(1, 1, 1, 1, 0.0, 1.0
342             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 10, 20, 10), 0, 0));
343     GreetingPanel.add(Greeting1);
344     gridBagLayout5.setConstraints(Greeting1, new GridBagConstraints2(0, 0, 2, 1, 0.0, 0.0
345             ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(20, 10, 10, 10), 0, 0));
346     RulePanel.setLayout(gridBagLayout6);
347     RuleButton.setLabel("I have read and understand the Rules of Use");
348     Rules.setBackground(Color.white);
349     RuleButton.setBackground(Color.white);
350     RuleBanner.setFont(new Font("Helvetica", 1, 14));
351     RuleBanner.setText("Please Read the Rules of Use");
352     RuleBanner.setBackground(Color.white);
353     RulePanel.add(RuleBanner);
354     gridBagLayout6.setConstraints(RuleBanner, new GridBagConstraints2(0, 0, 3, 1, 0.0, 0.0
355            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10,10, 10, 10), 0, 0));
356     RulePanel.add(Rules);
357     Rules.setEditable(false);
358     gridBagLayout6.setConstraints(Rules, new GridBagConstraints2(0, 1, 3, 1, 0.0, 0.0
359            ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10,10, 10, 10), 0, 0));
360     RulePanel.add(RuleButton);
361     gridBagLayout6.setConstraints(RuleButton, new GridBagConstraints2(2, 2, 1, 1, 0.0, 1.0
362            ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(10,10, 10, 10), 0, 0));
363     this.add("RulePanel", RulePanel);
364     showInit();
365   }
366
367   public void clear() {
368     LastName.setText("");
369     LoginName.setText("");
370     MiddleName.setText("");
371     FirstName.setText("");
372     MITID.setText("");
373     Password1.setText("");
374     Password2.setText("");
375     Word1.setText("");
376     Word2.setText("");
377     Word3.setText("");
378     Word4.setText("");
379     Word5.setText("");
380     Word6.setText("");
381     Pin.setText("");
382     guesslogin = "";
383     chosenlogin = "";
384   }
385
386   //Start the applet
387   public void start() {
388   }
389
390   //Stop the applet
391   public void stop() {
392   }
393
394   //Destroy the applet
395   public void destroy() {
396   }
397
398   //Get Applet information
399   public String getAppletInfo() {
400     return "Athena Registration Applet by Jeffrey I. Schiller 3/28/98";
401   }
402
403   //Get parameter info
404   public String[][] getParameterInfo() {
405     return null;
406   }
407
408   //Main method
409   static public void main(String[] args) {
410     Regapplet applet = new Regapplet();
411     applet.isStandalone = true;
412     Frame frame = new Frame();
413     frame.setTitle("Athena Registration Applet");
414     frame.add("Center", applet);
415     //    frame.add(BorderLayout.CENTER, applet);
416     applet.init();
417     applet.start();
418     //frame.pack();
419     //    frame.setSize(700,550);
420     frame.resize(910,550);
421     Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
422     //    frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
423     frame.show();
424     //    frame.setVisible(true);
425   }
426
427   public void showNameDiag() {
428     cardLayout1.show(this, "NamePanel");
429     FirstName.requestFocus();
430   }
431
432   public void showWordsDiag() {
433     cardLayout1.show(this, "WordPanel");
434     Word1.requestFocus();
435   }
436
437   public void showPinDiag() {
438     cardLayout1.show(this, "PinPanel");
439     Pin.requestFocus();
440   }
441
442   public void showLoginDiag() {
443     if (!guesslogin.equals("")) {
444       LoginNameBanner.setText(res.getString("getl1") + "\n" + res.getString("getl2") + " " + guesslogin + "\n" + res.getString("getl3"));
445     } else {
446       LoginNameBanner.setText(res.getString("getl1") + "\n" + res.getString("getl3"));
447     }
448     cardLayout1.show(this, "LoginPanel");
449     LoginName.requestFocus();
450   }
451
452   public void showLoginConfirmDiag() {
453     if (!chosenlogin.equals("")) {
454     LoginConfirmInstructions.setText("We have confirmed that the Athena username " + chosenlogin + " is available for your use." + "\n" + "If you choose to continue, your email address will be " + chosenlogin + "@mit.edu, and any personal web content you choose to publish will be available at the URL http://web.mit.edu/" + chosenlogin + "/www/ . After choosing to continue, this username will be registered for you without further confirmation, and CANNOT BE CHANGED." + "\n" + "Are you sure you would like to proceed?");
455     }
456     cardLayout1.show(this, "LoginConfirmPanel");
457     LoginConfirmContButton.requestFocus();
458   }
459
460   public void showPassDiag() {
461     cardLayout1.show(this, "PasswordPanel");
462     Password1.requestFocus();
463   }
464
465   public void showRules() {
466     cardLayout1.show(this, "RulePanel");
467     RuleButton.requestFocus();
468   }
469
470   public void showInit() {
471     if (worker != null) {
472        worker.close();
473        worker = null;
474     }
475     this.clear();
476     cardLayout1.show(this, "GreetingPanel");
477     GreetingButton.requestFocus();
478   }
479
480   public void showError() {
481     showMessage(res.getString("err"));
482   }
483
484   public void showError(boolean val) {
485     showMessage(res.getString("err"), val);
486   }
487
488   public void showError1(boolean val) {
489     if (isStandalone) {
490        showMessage(res.getString("err1"), val);
491     } else {
492        showMessage(res.getString("err1a"), val);
493     }
494   }
495
496   public void showMessage(String mess) {
497     mp.setText(mess, false);
498     cardLayout1.show(this, "MessagePanel");
499   }
500   public void showMessage(String mess, boolean contOK) {
501     mp.setText(mess, true);
502     cardLayout1.show(this, "MessagePanel");
503     mp.requestFocus();
504   }
505
506   private void doBale() {
507     if (worker != null) {
508       worker.oldstate = worker.state;
509       cardLayout1.show(this, "BalePanel");
510     }
511   }
512
513   public boolean keyDown(Event evt, int c) {
514     //    System.out.println("Applet: KeyDown: Event: " + evt.toString() + " c: " + c);
515     if (evt.target instanceof Button) {
516       if (c == 10) {
517         this.action(evt, ((Button) evt.target).getLabel());
518         return true;
519       }
520     }
521     return false;
522   }
523
524   public boolean action(Event evt, Object arg) {
525     System.err.println("action: " + evt.toString() + arg.toString());
526     if (evt.target == GreetingButton) {
527       if (worker != null) {
528         System.err.println("Worker not null when Greeting Button pressed!");
529       } else {
530         worker = new Worker(this);
531         workthread = new Thread(worker);
532         workthread.start();
533       }
534       return true;
535     } else if ((evt.target == WordContButton) ||
536                (evt.target == PinContButton) || 
537                (evt.target == LoginConfirmContButton) ||
538                (evt.target == LoginContButton) ||
539                (evt.target == PasswordContButton) ||
540                (evt.target == NameContButton) ||
541                (evt.target == MITID) ||
542                (evt.target == LoginName) ||
543                (evt.target == Word6) ||
544                (evt.target == Password2) ||
545                (evt.target == RuleButton)) {
546       workthread = new Thread(worker);
547       workthread.start();
548       return true;
549     } else if (evt.target == LoginConfirmCancelButton) {
550           chosenlogin = "";
551           showLoginDiag();
552     } else if (evt.target == ExitButton) {
553       if (isStandalone) System.exit (0);
554     } else if (evt.target == NameCancelButton ||
555                 evt.target == WordCancelButton ||
556                 evt.target == PinCancelButton ||
557                 evt.target == LoginCancelButton ||
558                 evt.target == PasswordCancelButton) {
559       doBale();
560       return true;
561     }
562     return false;
563   }
564 }
This page took 0.080158 seconds and 5 git commands to generate.