KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > demos > wb > UserInfoDialog


1 // $Id: UserInfoDialog.java,v 1.3 2004/09/23 16:29:34 belaban Exp $
2

3 package org.jgroups.demos.wb;
4
5 import java.awt.*;
6 import java.awt.event.ActionEvent JavaDoc;
7 import java.awt.event.ActionListener JavaDoc;
8
9
10
11 public class UserInfoDialog extends Dialog implements ActionListener JavaDoc {
12
13     final Button ok=new Button("OK");
14     final Label l=new Label("Name: ");
15     final TextField name=new TextField("");
16     private final Font default_font=new Font("Helvetica",Font.PLAIN,12);
17     
18
19     public UserInfoDialog(Frame parent) {
20     super(parent, "Input", true);
21     setLayout(null);
22
23     l.setFont(default_font);
24     l.setSize(50, 30);
25     l.setLocation(30, 50);
26
27     name.setFont(default_font);
28     name.setSize(150, 30);
29     name.setLocation(90, 50);
30     //name.selectAll();
31

32     ok.setFont(default_font);
33     ok.setSize(50, 30);
34     ok.setLocation(30, 90);
35     
36
37     add(l); add(name); add(ok);
38     ok.addActionListener(this);
39     setSize(300, 150);
40
41     Point my_loc=parent.getLocation();
42     my_loc.x+=50;
43     my_loc.y+=150;
44     setLocation(my_loc);
45     show();
46     }
47
48
49     public String JavaDoc getUserName() {
50     return name.getText();
51     }
52     
53
54     public void actionPerformed(ActionEvent JavaDoc e) {
55     String JavaDoc command=e.getActionCommand();
56     String JavaDoc tmp=name.getText();
57
58     if(command == "OK") {
59         if(tmp == null || tmp.length() < 1)
60         return;
61         else
62         dispose();
63     }
64     else
65         System.err.println("UserInfoDialog.actionPerfomed(): unknown action " +
66                    e.getActionCommand());
67     }
68
69
70 }
71
Popular Tags