import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class CallDialog extends Dialog implements ActionListener
{
    private static final long serialVersionUID = 6392371161413901973L;
    private GkClient gk;
	private Endpoint ep;

	private TextField edit;
	private Button call;

	public CallDialog(Frame _dw, GkClient _gk, Endpoint _ep)
	{
		super(_dw, "MakeCall", false);
		gk = _gk;
		ep = _ep;

		setBackground(Color.white);
		Panel p = new Panel();
		add(p);
		p.add(new Label("Destination:"));
		edit = new TextField(10);
		p.add(edit);
		call = new Button("Call");
		call.addActionListener(this);
		p.add(call);
		Button dont_call = new Button("Cancel");
		dont_call.addActionListener(this);
		p.add(dont_call);
		// needed to close the window with window controls
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				setVisible(false);	// close the window
			}
		});
	
		pack();
	}

	public void actionPerformed(ActionEvent e) {
		Object source = e.getSource();
		if (source == call) {
			gk.makeCall(ep.alias, edit.getText());
		}		
		setVisible(false);
	}
}
