01: // $Id: UserInfoDialog.java,v 1.5 2005/05/30 16:14:37 belaban Exp $
02:
03: package org.jgroups.demos.wb;
04:
05: import java.awt.*;
06: import java.awt.event.ActionEvent;
07: import java.awt.event.ActionListener;
08:
09: public class UserInfoDialog extends Dialog implements ActionListener {
10:
11: final Button ok = new Button("OK");
12: final Label l = new Label("Name: ");
13: final TextField name = new TextField("");
14: private final Font default_font = new Font("Helvetica", Font.PLAIN,
15: 12);
16:
17: public UserInfoDialog(Frame parent) {
18: super (parent, "Input", true);
19: setLayout(null);
20:
21: l.setFont(default_font);
22: l.setSize(50, 30);
23: l.setLocation(30, 50);
24:
25: name.setFont(default_font);
26: name.setSize(150, 30);
27: name.setLocation(90, 50);
28: //name.selectAll();
29:
30: ok.setFont(default_font);
31: ok.setSize(50, 30);
32: ok.setLocation(30, 90);
33:
34: add(l);
35: add(name);
36: add(ok);
37: ok.addActionListener(this );
38: setSize(300, 150);
39:
40: Point my_loc = parent.getLocation();
41: my_loc.x += 50;
42: my_loc.y += 150;
43: setLocation(my_loc);
44: show();
45: }
46:
47: public String getUserName() {
48: return name.getText();
49: }
50:
51: public void actionPerformed(ActionEvent e) {
52: String command = e.getActionCommand();
53: String tmp = name.getText();
54:
55: if (command == "OK") {
56: if (tmp == null || tmp.length() < 1)
57: return;
58: else
59: dispose();
60: } else
61: System.err
62: .println("UserInfoDialog.actionPerfomed(): unknown action "
63: + e.getActionCommand());
64: }
65:
66: }
|