public abstract class

AppletPanel

extends Panel
implements AppletStub Runnable
java.lang.Object
   ↳ java.awt.Component
     ↳ java.awt.Container
       ↳ java.awt.Panel
         ↳ sun.applet.AppletPanel

Class Overview

Applet panel class. The panel manages and manipulates the applet as it is being loaded. It forks a separate thread in a new thread group to call the applet's init(), start(), stop(), and destroy() methods.

Summary

Constants
int APPLET_DESTROY
int APPLET_DISPOSE
int APPLET_ERROR
int APPLET_INIT
int APPLET_LOAD
int APPLET_LOADING
int APPLET_LOADING_COMPLETED
int APPLET_QUIT
int APPLET_RESIZE
int APPLET_START
int APPLET_STOP
[Expand]
Inherited Constants
From class java.awt.Component
From interface java.awt.image.ImageObserver
Fields
protected boolean doInit Applet will allow initialization.
protected int status The current status.
Public Constructors
AppletPanel()
Public Methods
synchronized void addAppletListener(AppletListener l)
void appletResize(int width, int height)
Is called when the applet wants to be resized.
static void changeFrameAppContext(Frame frame, AppContext newAppContext)
void dispatchAppletEvent(int id, Object argument)
Dispatch event to the listeners..
synchronized static void flushClassLoader(String key)
Flush a class loader.
synchronized static void flushClassLoaders()
Flush all class loaders.
Applet getApplet()
Thread getAppletHandlerThread()
int getAppletHeight()
int getAppletWidth()
String getClassLoaderCacheKey()
Get caching key for classloader cache
abstract int getHeight()
Returns the current height of this component.
abstract int getWidth()
Returns the current width of this component.
abstract boolean hasInitialFocus()
void init()
Construct an applet viewer and start the applet.
boolean isActive()
Return true when the applet has been started.
Dimension minimumSize()
This method is deprecated. As of JDK version 1.1, replaced by getMinimumSize().
Dimension preferredSize()
This method is deprecated. As of JDK version 1.1, replaced by getPreferredSize().
synchronized void removeAppletListener(AppletListener l)
void run()
Execute applet events.
void sendEvent(int id)
Send an event.
void setBounds(int x, int y, int width, int height)
Moves and resizes this component.
Protected Methods
synchronized void clearLoadAbortRequest()
Applet createApplet(AppletClassLoader loader)
AppletClassLoader createClassLoader(URL codebase)
This method actually creates an AppletClassLoader.
abstract String getCode()
abstract String getJarFiles()
abstract String getSerializedObject()
boolean isJDK11Applet()
Return true if applet is targeted to JDK 1.1.
boolean isJDK12Applet()
Return true if applet is targeted to JDK1.2.
void loadJarFiles(AppletClassLoader loader)
synchronized boolean okToLoad()
synchronized void setLoadAbortRequest()
void setupAppletAppContext()
void showAppletException(Throwable t)
Called by the AppletPanel to provide feedback when an exception has happened.
void showAppletLog(String msg)
Called by the AppletPanel to print to the log.
void showAppletLog(String msg, Object arg)
void showAppletStatus(String status, Object arg)
void showAppletStatus(String status)
Status line.
void showAppletStatus(String status, Object arg1, Object arg2)
synchronized void stopLoading()
Request that the loading of the applet be stopped.
[Expand]
Inherited Methods
From class java.awt.Panel
From class java.awt.Container
From class java.awt.Component
From class java.lang.Object
From interface java.applet.AppletStub
From interface java.awt.MenuContainer
From interface java.awt.image.ImageObserver
From interface java.lang.Runnable
From interface javax.accessibility.Accessible

Constants

public static final int APPLET_DESTROY

Constant Value: 5 (0x00000005)

public static final int APPLET_DISPOSE

Constant Value: 0 (0x00000000)

public static final int APPLET_ERROR

Constant Value: 7 (0x00000007)

public static final int APPLET_INIT

Constant Value: 2 (0x00000002)

public static final int APPLET_LOAD

Constant Value: 1 (0x00000001)

public static final int APPLET_LOADING

Constant Value: 51235 (0x0000c823)

public static final int APPLET_LOADING_COMPLETED

Constant Value: 51236 (0x0000c824)

public static final int APPLET_QUIT

Constant Value: 6 (0x00000006)

public static final int APPLET_RESIZE

Constant Value: 51234 (0x0000c822)

public static final int APPLET_START

Constant Value: 3 (0x00000003)

public static final int APPLET_STOP

Constant Value: 4 (0x00000004)

Fields

protected boolean doInit

Applet will allow initialization. Should be set to false if loading a serialized applet that was pickled in the init=true state.

protected int status

The current status. One of: APPLET_DISPOSE, APPLET_LOAD, APPLET_INIT, APPLET_START, APPLET_STOP, APPLET_DESTROY, APPLET_ERROR.

Public Constructors

public AppletPanel ()

Public Methods

public synchronized void addAppletListener (AppletListener l)

public void appletResize (int width, int height)

Is called when the applet wants to be resized.

Parameters
width the new requested width for the applet.
height the new requested height for the applet.

public static void changeFrameAppContext (Frame frame, AppContext newAppContext)

public void dispatchAppletEvent (int id, Object argument)

Dispatch event to the listeners..

public static synchronized void flushClassLoader (String key)

Flush a class loader.

public static synchronized void flushClassLoaders ()

Flush all class loaders.

public Applet getApplet ()

public Thread getAppletHandlerThread ()

public int getAppletHeight ()

public int getAppletWidth ()

public String getClassLoaderCacheKey ()

Get caching key for classloader cache

public abstract int getHeight ()

Returns the current height of this component. This method is preferable to writing component.getBounds().height, or component.getSize().height because it doesn't cause any heap allocations.

Returns
  • the current height of this component

public abstract int getWidth ()

Returns the current width of this component. This method is preferable to writing component.getBounds().width, or component.getSize().width because it doesn't cause any heap allocations.

Returns
  • the current width of this component

public abstract boolean hasInitialFocus ()

public void init ()

Construct an applet viewer and start the applet.

public boolean isActive ()

Return true when the applet has been started.

Returns
  • true if the applet is active; false otherwise.

public Dimension minimumSize ()

This method is deprecated.
As of JDK version 1.1, replaced by getMinimumSize().

Minimum size

public Dimension preferredSize ()

This method is deprecated.
As of JDK version 1.1, replaced by getPreferredSize().

Preferred size

public synchronized void removeAppletListener (AppletListener l)

public void run ()

Execute applet events. Here is the state transition diagram Note: (XXX) is the action APPLET_XXX is the state (applet code loaded) --> APPLET_LOAD -- (applet init called)--> APPLET_INIT -- ( applet start called) --> APPLET_START -- (applet stop called) -->APPLET_STOP --(applet destroyed called) --> APPLET_DESTROY -->(applet gets disposed) --> APPLET_DISPOSE -->.... In the legacy lifecycle model. The applet gets loaded, inited and started. So it stays in the APPLET_START state unless the applet goes away(refresh page or leave the page). So the applet stop method called and the applet enters APPLET_STOP state. Then if the applet is revisited, it will call applet start method and enter the APPLET_START state and stay there. In the modern lifecycle model. When the applet first time visited, it is same as legacy lifecycle model. However, when the applet page goes away. It calls applet stop method and enters APPLET_STOP state and then applet destroyed method gets called and enters APPLET_DESTROY state. This code is also called by AppletViewer. In AppletViewer "Restart" menu, the applet is jump from APPLET_STOP to APPLET_DESTROY and to APPLET_INIT . Also, the applet can jump from APPLET_INIT state to APPLET_DESTROY (in Netscape/Mozilla case). Same as APPLET_LOAD to APPLET_DISPOSE since all of this are triggered by browser.

public void sendEvent (int id)

Send an event. Queue it for execution by the handler thread.

public void setBounds (int x, int y, int width, int height)

Moves and resizes this component. The new location of the top-left corner is specified by x and y, and the new size is specified by width and height.

Parameters
x the new x-coordinate of this component
y the new y-coordinate of this component
width the new width of this component
height the new height of this component

Protected Methods

protected synchronized void clearLoadAbortRequest ()

protected AppletClassLoader createClassLoader (URL codebase)

This method actually creates an AppletClassLoader. It can be override by subclasses (such as the Plug-in) to provide different classloaders.

protected abstract String getCode ()

protected abstract String getJarFiles ()

protected abstract String getSerializedObject ()

protected boolean isJDK11Applet ()

Return true if applet is targeted to JDK 1.1.

protected boolean isJDK12Applet ()

Return true if applet is targeted to JDK1.2.

protected void loadJarFiles (AppletClassLoader loader)

protected synchronized boolean okToLoad ()

protected synchronized void setLoadAbortRequest ()

protected void setupAppletAppContext ()

protected void showAppletException (Throwable t)

Called by the AppletPanel to provide feedback when an exception has happened.

protected void showAppletLog (String msg)

Called by the AppletPanel to print to the log.

protected void showAppletLog (String msg, Object arg)

protected void showAppletStatus (String status, Object arg)

protected void showAppletStatus (String status)

Status line. Called by the AppletPanel to provide feedback on the Applet's state.

protected void showAppletStatus (String status, Object arg1, Object arg2)

protected synchronized void stopLoading ()

Request that the loading of the applet be stopped.