All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bboss.org.jgroups.demos.wb.UserInfoDialog Maven / Gradle / Ivy

The newest version!
// $Id: UserInfoDialog.java,v 1.5 2005/05/30 16:14:37 belaban Exp $

package bboss.org.jgroups.demos.wb;

import java.awt.Button;
import java.awt.Dialog;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Label;
import java.awt.Point;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;



public class UserInfoDialog extends Dialog implements ActionListener {

    final Button              ok=new Button("OK");
    final Label               l=new Label("Name: ");
    final TextField           name=new TextField("");
    private final Font  default_font=new Font("Helvetica",Font.PLAIN,12);
    

    public UserInfoDialog(Frame parent) {
	super(parent, "Input", true);
	setLayout(null);

	l.setFont(default_font);
	l.setSize(50, 30);
	l.setLocation(30, 50);

	name.setFont(default_font);
	name.setSize(150, 30);
	name.setLocation(90, 50);
	//name.selectAll();

	ok.setFont(default_font);
	ok.setSize(50, 30);
	ok.setLocation(30, 90);
	

	add(l);	add(name); add(ok);
	ok.addActionListener(this);
	setSize(300, 150);

	Point my_loc=parent.getLocation();
	my_loc.x+=50;
	my_loc.y+=150;
	setLocation(my_loc);
	show();
    }


    public String getUserName() {
	return name.getText();
    }
    

    public void actionPerformed(ActionEvent e) {
	String     command=e.getActionCommand();
	String     tmp=name.getText();

	if(command == "OK") {
	    if(tmp == null || tmp.length() < 1)
		return;
	    else
		dispose();
	}
	else
        System.err.println("UserInfoDialog.actionPerfomed(): unknown action " +
                           e.getActionCommand());
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy