Java Example Program / Sample Source Code
import java.applet.*;
import java.awt.*;
import java.net.*;
import java.awt.event.*;
public class LoadHtmlApplet extends Applet implements ActionListener {
public void init() {
Button button = new Button("go to Google");
button.addActionListener(this);
add(button);
}
public void actionPerformed(ActionEvent ae) {
try {
URL url = new URL(getDocumentBase(), "http://www.google.com");
// using _blank to open a new window
// using _self to open in same window
getAppletContext().showDocument(url, "_self");
} catch (MalformedURLException e) {
showStatus("URL not found");
}
}
} |
|
|