gishur.applet
Class ApplicationContext

java.lang.Object
  |
  +--gishur.applet.ApplicationContext
All Implemented Interfaces:
java.applet.AppletContext

public class ApplicationContext
extends java.lang.Object
implements java.applet.AppletContext

ApplicationContext verwaltet mehrere Appltes un hilft, Applets als Applications laufen zu lassen. ApplicationContext übernimmt dabei die Rolle des AppletContextes bei normalen Applet.
Mit registerApplet können Applets registriert, mit initApplet initialisiert und mit start und stop bzw. destroy gestartet, gestoppt oder zerstört werden. Für jedes Applet kann noch ein CloseMode festgelegt werden; damit kann ein Applet beim Schließen beispielsweise automatische alle aktiven Applets beenden. Mit setSystemExitMode kann man festlegen, ob die Applikation beendet werden soll, wenn alle Applets beendet wurden. Beim Registrieren wird für das Applet ein AppletStub, in dem Fall ein ApplicationStub erzeugt und mit dem Applet verknüpft. Der ApplicationStub übernimmt die Erstellung des Appletfensters und steuert die Applet-Aktionen init/start/stop/destroy.
ApplicationAppplet Vereinfacht den Zugriff auf ApplicationContext etwas, es können aber beliebige bestehende Applets gestartet werden.

Version:
1.0
Author:
Thomas Wolf
See Also:
ApplicationStub, AppletControl, ApplicationApplet

Field Summary
static byte ALL_DESTROYED
          Konstante für setSystemExitMode: Applikation wird beendet, wenn alle Applets zerstört wurden.
static byte ALL_STOPPED
          Konstante für setSystemExitMode: Applikation wird beendet, wenn alle Applets gestoppt wurden.
static byte DESTROY_ALL
          Zerstört alle Applets, wenn dieses Applet zerstört wird.
static byte NOTHING
          Nichts weiter passiert, wenn das Applet gestoppt wird.
static byte STOP_ALL
          Alle Applets werden gestoppt, wenn dieses Applet gestoppt wird.
 
Method Summary
 void destroyAllApplets()
          Stoppt und zerstört alle Applets
 void destroyApplet(java.applet.Applet applet)
          Beendet das Applet applet.
 java.applet.Applet getApplet(java.lang.String name)
          Finds and returns the applet in the document represented by this applet context with the given name.
 AppletControl getAppletControl(java.applet.Applet applet)
          Liefert das AppletWindowControl-Objekt des Applets applet.
 java.lang.String getAppletName(java.applet.Applet applet)
          Liefert den Namen des Applets applet.
 java.util.Enumeration getApplets()
          Finds all the applets in the document represented by this applet context.
 java.applet.AudioClip getAudioClip(java.net.URL url)
          Creates an audio clip.
 java.net.URL getCodeBase()
          Liefert die Code-Base-URL für alle verknüpften Applets.
 java.lang.String getCodeBasePath()
          Liefert den gesetzten CodeBasePath.
 java.net.URL getDocumentBase()
          Liefert die Document-Base-URL für alle verknüpften Applets.
 java.awt.Image getImage(java.net.URL url)
          Returns an Image object that can then be painted on the screen.
 void initApplet(java.applet.Applet applet, java.awt.Container container, int pos)
          Initialisiert das Applet applet und fügt es an den Container an Position pos an.
 void initApplet(java.applet.Applet applet, java.lang.String title, int width, int height)
          Initialisiert das Applet applet und setzt den Titel sowie die Größe des Appletfensters.
 void initApplet(java.applet.Applet applet, java.lang.String name, java.lang.String title, int width, int height)
          Registriert und initialisiert das Applet applet und setzt den Titel des Appletfensters.
 void registerApplet(java.applet.Applet applet, java.lang.String name)
          Registriert das Applet applet mit dem Namen name bei diesem AppletContext.
 void setCodeBasePath(java.lang.String path)
          Setzt den Pfad für Code-Base und Document-Base für die Simulation eines Applets.
 void setStopMode(java.applet.Applet applet, byte mode)
          Setzt den Stopmode des Applets applet, d.h bestimmt, was passiert, wenn applet gestoppt bzw. zerstört wird.
 void setSystemExitMode(byte mode)
          Legt fest, wann eine Application durch SystemExit beendet werden soll.
 void showDocument(java.net.URL url)
          Replaces the Web page currently being viewed with the given URL.
 void showDocument(java.net.URL url, java.lang.String target)
          Requests that the browser or applet viewer show the Web page indicated by the url argument.
 void showStatus(java.lang.String status)
          Requests that the argument string be displayed in the "status window".
 void startApplet(java.applet.Applet applet)
          Startet das Applet applet.
 void startApplet(java.lang.String name, java.applet.Applet applet, int width, int height, java.lang.String title)
          Startet das Applet Applet mit dem Namen name in einem Fenster der Breite width und Höhe height mit dem Titel title.
 void stopAllApplets()
          Stoppt alle Applets.
 void stopApplet(java.applet.Applet applet)
          Stoppt das Applet applet.
 void unregisterApplet(java.applet.Applet applet)
          Entfernt das Applet applet von der Liste registrierter Applets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOTHING

public static final byte NOTHING
Nichts weiter passiert, wenn das Applet gestoppt wird.

STOP_ALL

public static final byte STOP_ALL
Alle Applets werden gestoppt, wenn dieses Applet gestoppt wird.

DESTROY_ALL

public static final byte DESTROY_ALL
Zerstört alle Applets, wenn dieses Applet zerstört wird.

ALL_STOPPED

public static final byte ALL_STOPPED
Konstante für setSystemExitMode: Applikation wird beendet, wenn alle Applets gestoppt wurden.

ALL_DESTROYED

public static final byte ALL_DESTROYED
Konstante für setSystemExitMode: Applikation wird beendet, wenn alle Applets zerstört wurden.
Method Detail

registerApplet

public void registerApplet(java.applet.Applet applet,
                           java.lang.String name)
Registriert das Applet applet mit dem Namen name bei diesem AppletContext. An dieser Stelle wird ein ApplicationStub für das Applet angelegt und das Applet damit verknüpft.
Parameters:
applet - zu registrierendes Applet
name - Applet-Name

unregisterApplet

public void unregisterApplet(java.applet.Applet applet)
Entfernt das Applet applet von der Liste registrierter Applets. Läuft das Applet, wird stop() aufgerufen, außerdem destroy(), falls es initialisiert wurde.
Parameters:
applet - zu entfernendes Applet

setStopMode

public void setStopMode(java.applet.Applet applet,
                        byte mode)
Setzt den Stopmode des Applets applet, d.h bestimmt, was passiert, wenn applet gestoppt bzw. zerstört wird.
Parameters:
applet - Applet
mode - Stopmode (eine Konstante aus {NOTHING,CLOSE_ALL,DESTROY_ALL})

initApplet

public void initApplet(java.applet.Applet applet,
                       java.lang.String title,
                       int width,
                       int height)
Initialisiert das Applet applet und setzt den Titel sowie die Größe des Appletfensters. Das Applet muß vorher mit registerApplet registriert worden sein.
Parameters:
applet - zu initialisierendes Applet
title - Titel des Appletfensters
width - Breite des AppletFensters
height - Höhe des AppletFensters

initApplet

public void initApplet(java.applet.Applet applet,
                       java.awt.Container container,
                       int pos)
Initialisiert das Applet applet und fügt es an den Container an Position pos an. Das Applet muß vorher mit registerApplet registriert worden sein.
Parameters:
applet - zu initialisierendes Applet
container - Container
pos - Position im Container

initApplet

public void initApplet(java.applet.Applet applet,
                       java.lang.String name,
                       java.lang.String title,
                       int width,
                       int height)
Registriert und initialisiert das Applet applet und setzt den Titel des Appletfensters.
Parameters:
applet - zu initialisierendes Applet
name - Applet-Name
title - Titel des Appletfensters
width - Breite des AppletFensters
height - Höhe des AppletFensters

startApplet

public void startApplet(java.applet.Applet applet)
Startet das Applet applet. Das Applet muß vorher registriert und initialisiert worden sein.
Parameters:
applet - zu startendes Applet

startApplet

public void startApplet(java.lang.String name,
                        java.applet.Applet applet,
                        int width,
                        int height,
                        java.lang.String title)
Startet das Applet Applet mit dem Namen name in einem Fenster der Breite width und Höhe height mit dem Titel title.
Parameters:
name - Applet-Name
applet - zu startendes Applet
width - Breite des AppletFensters
height - Höhe des AppletFensters
title - Titel des Appletfensters

stopApplet

public void stopApplet(java.applet.Applet applet)
Stoppt das Applet applet.
Parameters:
applet - Applet

stopAllApplets

public void stopAllApplets()
Stoppt alle Applets.

destroyAllApplets

public void destroyAllApplets()
Stoppt und zerstört alle Applets

destroyApplet

public void destroyApplet(java.applet.Applet applet)
Beendet das Applet applet.
Parameters:
applet - Applet

getAppletName

public java.lang.String getAppletName(java.applet.Applet applet)
Liefert den Namen des Applets applet.
Parameters:
applet - Applet
Returns:
Name

setSystemExitMode

public void setSystemExitMode(byte mode)
Legt fest, wann eine Application durch SystemExit beendet werden soll.
Parameters:
mode - neuer SystemExitMode:
  • mode==NOTHING beendet nie
  • mode==ALL_STOPPED beendet, falls alle Applets gestoppt wurden
  • mode==ALL_DESTROYED beendet, falls alle Applets zerstört wurden

setCodeBasePath

public void setCodeBasePath(java.lang.String path)
Setzt den Pfad für Code-Base und Document-Base für die Simulation eines Applets. Diese Methode zeigt keine Wirkung bei einem ApplicationContext, der auf einem richtigen Applet basiert.
Parameters:
path - neuer Pfad

getCodeBasePath

public java.lang.String getCodeBasePath()
Liefert den gesetzten CodeBasePath. Dieser Wert ist nur gültig, falls der ApplicationContext nicht auf einem Applet basiert.
Returns:
Pfad

getCodeBase

public java.net.URL getCodeBase()
Liefert die Code-Base-URL für alle verknüpften Applets.
Returns:
Code-Base-URL

getDocumentBase

public java.net.URL getDocumentBase()
Liefert die Document-Base-URL für alle verknüpften Applets.
Returns:
Document-Base-URL

getAppletControl

public AppletControl getAppletControl(java.applet.Applet applet)
Liefert das AppletWindowControl-Objekt des Applets applet.
Parameters:
applet - Applet
Returns:
AppletWindowsControl-Objekt des Applets applet

getAudioClip

public java.applet.AudioClip getAudioClip(java.net.URL url)
Creates an audio clip.
Specified by:
getAudioClip in interface java.applet.AppletContext
Parameters:
url - an absolute URL giving the location of the audio clip.
Returns:
the audio clip at the specified URL.
Since:
JDK1.0

getImage

public java.awt.Image getImage(java.net.URL url)
Returns an Image object that can then be painted on the screen. The url argument that is passed as an argument must specify an absolute URL.

This method always returns immediately, whether or not the image exists. When the applet attempts to draw the image on the screen, the data will be loaded. The graphics primitives that draw the image will incrementally paint on the screen.

Specified by:
getImage in interface java.applet.AppletContext
Parameters:
url - an absolute URL giving the location of the image.
Returns:
the image at the specified URL.
Since:
JDK1.0
See Also:
Image

getApplet

public java.applet.Applet getApplet(java.lang.String name)
Finds and returns the applet in the document represented by this applet context with the given name. The name can be set in the HTML tag by setting the name attribute.
Specified by:
getApplet in interface java.applet.AppletContext
Parameters:
name - an applet name.
Returns:
the applet with the given name, or null if not found.
Since:
JDK1.0

getApplets

public java.util.Enumeration getApplets()
Finds all the applets in the document represented by this applet context.
Specified by:
getApplets in interface java.applet.AppletContext
Returns:
an enumeration of all applets in the document represented by this applet context.
Since:
JDK1.0

showDocument

public void showDocument(java.net.URL url)
Replaces the Web page currently being viewed with the given URL. This method may be ignored by applet contexts that are not browsers.
Specified by:
showDocument in interface java.applet.AppletContext
Parameters:
url - an absolute URL giving the location of the document.
Since:
JDK1.0

showDocument

public void showDocument(java.net.URL url,
                         java.lang.String target)
Requests that the browser or applet viewer show the Web page indicated by the url argument. The target argument indicates where to display the frame. The target argument is interpreted as follows:

"_self" show in the current frame
"_parent"show in the parent frame
"_top" show in the topmost frame
"_blank" show in a new unnamed top-level window
nameshow in a new top-level window named name

An applet viewer or browser is free to ignore showDocument.

Specified by:
showDocument in interface java.applet.AppletContext
Parameters:
url - an absolute URL giving the location of the document.
target - a String indicating where to display the page.
Since:
JDK1.0

showStatus

public void showStatus(java.lang.String status)
Requests that the argument string be displayed in the "status window". Many browsers and applet viewers provide such a window, where the application can inform users of its current state.
Specified by:
showStatus in interface java.applet.AppletContext
Parameters:
status - a string to display in the status window.
Since:
JDK1.0