
/*
 * A dialog box for the user to enter conference information
 * such as session name, description, and multicast address.
 * Invoked from the CallerDialog client when the user selects
 * conference as the type of call s/he wishes to make.
 *
 * Author: Janet H. Park
 * Date: August, 1998
 *
 */

import java.awt.*;

public class ConfDialog extends Dialog
{
	public ConfDialog(Frame parent, boolean modal)
	{
		super(parent, modal);

		// This code is automatically generated by Visual Cafe when you add
		// components to the visual environment. It instantiates and initializes
		// the components. To modify the code, only use code syntax that matches
		// what Visual Cafe can generate, or Visual Cafe may be unable to back
		// parse your Java file into its visual environment.
		//{{INIT_CONTROLS
		GridBagLayout gridBagLayout;
		gridBagLayout = new GridBagLayout();
		setLayout(gridBagLayout);
		setVisible(false);
		setSize(insets().left + insets().right + 383,insets().top + insets().bottom + 194);
		panel1 = new java.awt.Panel();
		panel1.setLayout(null);
		panel1.setBounds(insets().left + 10,insets().top + 10,363,174);
		panel1.setForeground(new Color(-16777125));
		panel1.setBackground(new Color(-3545857));
		GridBagConstraints gbc;
		gbc = new GridBagConstraints();
		gbc.weightx = 100.0;
		gbc.weighty = 100.0;
		gbc.fill = GridBagConstraints.BOTH;
		gbc.insets = new Insets(10,10,10,10);
		((GridBagLayout)getLayout()).setConstraints(panel1, gbc);
		add(panel1);
		labelAddr = new java.awt.Label("multicast address:",Label.RIGHT);
		labelAddr.setBounds(2,86,120,24);
		labelAddr.setFont(new Font("Dialog", Font.PLAIN, 12));
		panel1.add(labelAddr);
		textFieldAddr = new java.awt.TextField();
		textFieldAddr.setBounds(144,85,132,28);
		panel1.add(textFieldAddr);
		buttonDone = new java.awt.Button();
		buttonDone.setActionCommand("button");
		buttonDone.setLabel("Done");
		buttonDone.setBounds(194,134,72,24);
		buttonDone.setBackground(new Color(-5984570));
		panel1.add(buttonDone);
		labelName = new java.awt.Label("conference name:",Label.RIGHT);
		labelName.setBounds(2,26,120,24);
		labelName.setFont(new Font("Dialog", Font.PLAIN, 12));
		panel1.add(labelName);
		textFieldName = new java.awt.TextField();
		textFieldName.setBounds(144,21,206,28);
		panel1.add(textFieldName);
		textFieldInfo = new java.awt.TextField();
		textFieldInfo.setBounds(144,53,205,28);
		textFieldInfo.setBackground(new Color(-3545857));
		panel1.add(textFieldInfo);
		labelInfo = new java.awt.Label("conference info:",Label.RIGHT);
		labelInfo.setBounds(14,58,106,24);
		panel1.add(labelInfo);
		buttonClear = new java.awt.Button();
		buttonClear.setActionCommand("button");
		buttonClear.setLabel("Clear");
		buttonClear.setBounds(86,134,72,24);
		buttonClear.setBackground(new Color(-5984569));
		panel1.add(buttonClear);
		setTitle("Conference Information");
		//}}

		//{{REGISTER_LISTENERS
		SymWindow aSymWindow = new SymWindow();
		this.addWindowListener(aSymWindow);
		SymAction lSymAction = new SymAction();
		buttonClear.addActionListener(lSymAction);
		buttonDone.addActionListener(lSymAction);
		//}}
	}
	
	public void addNotify()
	{
  	    // Record the size of the window prior to calling parents addNotify.
	    Dimension d = getSize();

		super.addNotify();

		if (fComponentsAdjusted)
			return;

		// Adjust components according to the insets
		setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
		Component components[] = getComponents();
		for (int i = 0; i < components.length; i++)
		{
			Point p = components[i].getLocation();
			p.translate(insets().left, insets().top);
			components[i].setLocation(p);
		}
		fComponentsAdjusted = true;
	}

    // Used for addNotify check.
	boolean fComponentsAdjusted = false;


	public ConfDialog(Frame parent, String title, boolean modal)
	{
		this(parent, modal);
		setTitle(title);
	}

	public synchronized void show()
	{
		Rectangle bounds = getParent().bounds();
		Rectangle abounds = bounds();

		move(bounds.x + (bounds.width - abounds.width)/ 2,
			 bounds.y + (bounds.height - abounds.height)/2);

		super.show();
	}

	//{{DECLARE_CONTROLS
	java.awt.Panel panel1;
	java.awt.Label labelAddr;
	java.awt.TextField textFieldAddr;
	java.awt.Button buttonDone;
	java.awt.Label labelName;
	java.awt.TextField textFieldName;
	java.awt.TextField textFieldInfo;
	java.awt.Label labelInfo;
	java.awt.Button buttonClear;
	//}}

	class SymWindow extends java.awt.event.WindowAdapter
	{
		public void windowClosing(java.awt.event.WindowEvent event)
		{
			Object object = event.getSource();
			if (object == ConfDialog.this)
				Dialog1_WindowClosing(event);
		}
	}
	
	void Dialog1_WindowClosing(java.awt.event.WindowEvent event)
	{
		hide();
	}

	class SymAction implements java.awt.event.ActionListener
	{
		public void actionPerformed(java.awt.event.ActionEvent event)
		{
			Object object = event.getSource();
			if (object == buttonClear)
				buttonClear_Action(event);
			else if (object == buttonDone)
				buttonDone_Action(event);
		}
	}

	void buttonClear_Action(java.awt.event.ActionEvent event)
	{
		// to do: code goes here.
			 
		//{{CONNECTION
		// Clear the text for TextField
		textFieldAddr.setText("");
		//}}
			 

		//{{CONNECTION
		// Clear the text for TextField
		textFieldName.setText("");
		//}}
			 
		//{{CONNECTION
		// Clear the text for TextField
		textFieldInfo.setText("");
		//}}
	}

	void buttonDone_Action(java.awt.event.ActionEvent event)
	{
		// to do: code goes here.

		
		name = textFieldName.getText().trim();
		info = textFieldInfo.getText().trim();
		addr = textFieldAddr.getText().trim();
			 
		//{{CONNECTION
		// Hide the Dialog
		setVisible(false);
		//}}
	}

	String name() { return name; }
	String info() { return info; }
	String addr() { return addr; }
	String port() { return port; }


	String name = "";
	String info = "";
	String addr = "224.2.0.1";
	String port = "9090";
	
}
