Java Source code for Geturl


The following Java code will get the URL.

import java.awt.*;
import java.applet.*;
import java.net.*; public class AppGetURL extends Applet {
URL getUrlName = null; 

void buttonGetUrl_Clicked(Event event) {
try {
getUrlName=new URL(textFieldUrl.getText());
getAppletContext().showDocument(getUrlName);}
catch(Exception e) {
label2.setText("Unable to open Url :  "+textFieldUrl.getText());
label2.reshape(9,67,313,15);
label2.show(); }
}

public void init() {
super.init();
setLayout(null);
addNotify();
resize(434,89);
textFieldUrl = new java.awt.TextField();
textFieldUrl.reshape(4,30,322,24);
add(textFieldUrl);
buttonGetUrl = new java.awt.Button("Get");
buttonGetUrl.reshape(336,29,89,25);
add(buttonGetUrl);
label1 = new java.awt.Label("Write Url (with http://) and press Get!");
label1.reshape(42,8,200,15);
add(label1);
label2 = new java.awt.Label("label");
label2.hide();
label2.reshape(9,67,47,15);
add(label2);
//}}
}

public boolean handleEvent(Event event) {
if (event.target == buttonGetUrl && event.id == Event.ACTION_EVENT) {
buttonGetUrl_Clicked(event);
}
return super.handleEvent(event);
}

java.awt.TextField textFieldUrl;
java.awt.Button buttonGetUrl;
java.awt.Label label1;
java.awt.Label label2;
}}
}




Added on June 30, 2007 Comment
}