import java.awt.Button;
import java.awt.Color;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class TransferDialog extends Dialog implements ActionListener
{
    private static final long serialVersionUID = -1668064055953723962L;
    private GkClient gk;
	private Endpoint ep;

	private TextField edit;
	private Button transfer;

	public TransferDialog(Frame _dw, GkClient _gk, Endpoint _ep)
	{
        super(_dw, "TransferCall", 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);
		transfer = new Button("Transfer");
		transfer.addActionListener(this);
		p.add(transfer);
		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 == transfer) {
			gk.transferCall(ep.alias, edit.getText());
		}		
		setVisible(false);
	}
}
