Applet Status And Event Handlers

These documentation pages are no longer current. They remain available for archival purposes. Please visit for the most up-to-date documentation.

Java Rich Internet Applications Guide > Applet Developer's Guide > Applet Status and Event Handlers

Beginning in the Java SE 7 release, you can check the value of the status variable of an applet while it is being initialized. This check is non-blocking and immediately returns the status of the applet. You can explicitly check the status of the applet while it is loading and perform relevant actions or register event handlers that will automatically be invoked during various stages of applet initialization. The applet should be deployed with the java_status_events parameter set to true in order to use this functionality. See the Handling Initialization Status With Event Handlers topic in the Java Tutorials for step by step instructions and an example.

Applet Status

The following table displays the meaning of values returned by the status method of the applet.

Applet Status Values and Meaning
Applet Status Applet Status Variable Value Meaning
LOADING 1 Applet is loading
READY 2 Applet has loaded completely and is ready to receive JavaScript calls
ERROR 3 Error while loading applet

Applet Event Handlers

You can register event handlers for various events. The Java Plug-in software will invoke these event handlers at various stages of the applet loading process. The following table describes applet events for which event handlers can be registered.

Applet Events
Applet Event When Event Occurs
onLoad Occurs when applet status is READY. Applet has finished loading and is ready to receive JavaScript calls
onStop Occurs when applet has stopped
onError Occurs when applet status is ERROR. An error has occurred while loading the applet

You can register or determine an event handler in the JavaScript code of a web page as shown in the following code snippets.

// use an anonymous function
applet.onLoad(function() {
  //event handler for ready state

// use a regular function
function onLoadHandler() {
  // event handler for ready state

// Use method form

// Use attribute form
applet.onLoad = onLoadHandler;

// get current event handler
var handler = applet.onLoad

Copyright © 1993, 2017, Oracle and/or its affiliates. All rights reserved.