O'Reilly logo

Java Garage by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Few Applet Tricks

Here are a few neat things that you can do within your applet, including some that might be downright necessary.

Showing a Message in the Browser's Status Bar

The status bar of the browser typically will display messages in the bottom-left corner. This feature is so retro mid-90s, it is impossible to resist.

applet.showStatus("All your base are belong to us. Ha ha ha");

Nuff said.

Making the Browser Visit a URL

You can redirect the browser using the showDocument() method, like this:

try {
        URL url = new URL(getDocumentBase(),
        "http://www.example.com/some.jsp");
        applet.getAppletContext().showDocument(url);
     } catch (MalformedURLException e) {
//deal
     }

Passing Parameters into Applets

You can pass a parameter into an applet ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required