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 ...

Get Java Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.