/*************************************************
 * Author: 	Evelyn Lai-Tee Cheok
 *			Department of Electrical Engineering
 *			Center for Telecommunications Research
 *			Schapiro Research Building
 *			Columbia University
 *
 * Email: 	laitee@ctr.columbia.edu
 *
 **************************************************/
import java.lang.*;
import java.awt.*;
import MyLabel;
import MyTextBox;
import MenuWindow;

/** Class for the popup window associated with the supervisor
	option on the sub menu. Allows users to change the session
	bandwidth. This is much more for experimenting and demo
	purposes to illustrate the effect of a change in bandwidth on
	the RTCP transmission interval. **/
public class SuperSettingWindow extends Frame {
	MyTextBox session_bw;
	MenuWindow main_parent;

	/** Constructor function for building the user interface **/
	public SuperSettingWindow (String title, 
						MenuWindow parent) {
		super(title);
		main_parent = parent;
		GridBagLayout gridbag = new GridBagLayout();
		setLayout(gridbag);

		session_bw = new MyTextBox(gridbag, 10, "REMAINDER",
									10, 5, 10, 10);
		add(new MyLabel(gridbag, "Set Session Bandwidth :",
						Label.LEFT, "RELATIVE", 10, 10, 10, 5));
		session_bw.setText(new Double(main_parent.state_info.session_bw).toString());
		add(session_bw);
		add(new MyButton(gridbag, "OK", "REMAINDER", 10,50,10,50));
		session_bw.selectAll();
		resize(400, 200);
	}

	/** Event handler for traping ACTIO_EVENT on the OK button, after 
		which the entered bandwidth values is stored into the StateInfo
		class of the user **/
	public boolean action(Event e, Object what) {
		double value;
		if (e.target instanceof MyButton) {
			if (e.arg == "OK") {
				if (session_bw.getText() != null) {
					value = (new Double(session_bw.getText())).doubleValue();
					main_parent.state_info.session_bw = value;
					if (this.isShowing()) {
						this.hide();
						removeAll();
					}
				}
				else
					System.out.println("Default value used!");
			}
		return true;
		}
		return false;
	}

}

		
