import java.lang.*;
import java.awt.*;
import MyLabel;
import MyButton;
import MyTextBox;

public class OpenURLDialog extends Frame {
	MyTextBox textbox;
	MyButton OKBtn;

	public OpenURLDialog(String title) {
		super(title);

		GridBagLayout gridbag = new GridBagLayout();
		GridBagConstraints c = new GridBagConstraints();
		setLayout(gridbag);

		textbox = new MyTextBox(gridbag, 10, "REMAINDER",
								5,10,10,10);
		OKBtn = new MyButton(gridbag, "OK", "REMAINDER", 
								10,10,10,10);								
		add( new MyLabel(gridbag, "Please enter URL location :", Label.LEFT,
					"REMAINDER", 10,10,5,10));
		add(textbox);
		add(OKBtn);
		resize(300,300);
	}

	public boolean action(Event e, Object what) {
		if (e.arg.equals("OK")) {
			String textString = textbox.getText();
			if (textString.length() != 0) {
				openURL(textString);
				textString = null;
				if (this.isShowing()) {
					removeAll();
					this.hide();
				}
			}
			else
				System.out.println("Please enter a URL address");

		}
		return true;
	}

    public void openURL(String url) {
        Runtime myRuntime = Runtime.getRuntime();
		String cmd = "/proj/sirius2/packages/Netscape/solaris2.3/Netscape.sh";
 
        String args = " -remote openURL(" + url + ")";
 
        try {
            myRuntime.exec(cmd + args);
        } catch (java.io.IOException e) {
            System.out.println("IOException : "+e);
        }
 
        System.out.println("$$ END of openURL");
    }

}

