com.sas.util
Class AppletHost

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--com.sas.util.AppletHost
All Implemented Interfaces:

public class AppletHost
extends java.awt.Frame
implements java.applet.AppletStub, java.applet.AppletContext, java.awt.event.ActionListener

AppletHost - implements AppletContext and AppletStub to allow any applet to easily run as an application. The only thing it can't do is access URL's. Applet parameters are entered on the command line with name as one word and value as the next.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Inner classes inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Inner classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  Vector applets
           
protected  int initial_height
           
protected  int initial_width
           
protected  Hashtable params
           
protected  Button startButton
           
protected  TextField status
           
protected  Button stopButton
           
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AppletHost(Applet applet, int default_width, int default_height, String[] args)
          Constructor for the main class, given an existing applet object and a default frame (window) width and height.
AppletHost(Applet applet, String[] args)
          Constructor for the main class, given an existing applet object.
AppletHost(String[] args)
          Constructor for the main class, from the command line arguments.
AppletHost(String appletClassName, int default_width, int default_height, String[] args)
          Constructor for the main class, given a name of an applet object and a default frame (window) width and height.
 
Method Summary
 void actionPerformed(ActionEvent evt)
           
 void appletResize(int width, int height)
          Called when the applet wants to be resized.
 Applet getApplet(String name)
          Gets an applet by name.
 AppletContext getAppletContext()
          Gets a handler to the applet's context.
 Enumeration getApplets()
          Enumerates the applets in this context.
 AudioClip getAudioClip(URL url)
          Gets an audio clip.
 URL getCodeBase()
          Gets the codebase URL.
 URL getDocumentBase()
          Gets the document URL.
 Image getImage(URL url)
          Gets an image.
 String getParameter(String name)
          Gets a parameter of the applet.
 InputStream getStream(String key)
          Returns the stream to which specified key is associated within this applet context.
 Iterator getStreamKeys()
          Finds all the keys of the streams in this applet context.
 boolean isActive()
          Returns true if the applet is active.
static void main(String[] args)
          Entry point into the standalone program.
 void parseArgs(String[] args, int startidx)
          Parse the command line arguments.
 void processWindowEvent(WindowEvent evt)
           
 void setStream(String key, InputStream stream)
          Associates the specified stream with the specified key in this applet context.
 void showDocument(URL url)
          Shows a new document.
 void showDocument(URL url, String target)
          Show a new document in a target window or frame.
 void showStatus(String text)
          Show a status string in the status area (the Text object at the bottom of the window.
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

status

protected TextField status

startButton

protected Button startButton

stopButton

protected Button stopButton

params

protected Hashtable params

applets

protected Vector applets

initial_width

protected int initial_width

initial_height

protected int initial_height
Constructor Detail

AppletHost

public AppletHost(Applet applet,
                  String[] args)
Constructor for the main class, given an existing applet object.
Parameters:
applet - the applet embedded in this AppletContext
args - the command line arguments. Contains possibly height and width, and any applet parameters

AppletHost

public AppletHost(Applet applet,
                  int default_width,
                  int default_height,
                  String[] args)
Constructor for the main class, given an existing applet object and a default frame (window) width and height.
Parameters:
applet - the applet embedded in this AppletContext
default_width - the default width of the window
default_height - the default width of the window
args - the command line arguments. Contains possibly height and width, and any applet parameters

AppletHost

public AppletHost(String appletClassName,
                  int default_width,
                  int default_height,
                  String[] args)
Constructor for the main class, given a name of an applet object and a default frame (window) width and height.
Parameters:
appletClassName - the applet embedded in this AppletContext
default_width - the default width of the window
default_height - the default width of the window
args - the command line arguments. Contains possibly height and width, and any applet parameters

AppletHost

public AppletHost(String[] args)
Constructor for the main class, from the command line arguments.
Parameters:
args - the command line arguments. Contains the name of the applet class, possibly height and width, and any applet parameters.
Method Detail

main

public static void main(String[] args)
Entry point into the standalone program.
Parameters:
args - the command line arguments

parseArgs

public void parseArgs(String[] args,
                      int startidx)
Parse the command line arguments. Get the initial width and height of the window if specified (-width [value] -height [value]), and the applet parameters (name value pairs, or name=value).
Parameters:
args - the command line arguments. Contains possibly height and width, and any applet parameters
startidx - index in the args array at which to start parsing

processWindowEvent

public void processWindowEvent(WindowEvent evt)
Overrides:
processWindowEvent in class Window

actionPerformed

public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener

isActive

public boolean isActive()
Returns true if the applet is active.
Specified by:
isActive in interface AppletStub
Overrides:
isActive in class Window
Returns:
always true

getDocumentBase

public URL getDocumentBase()
Gets the document URL.
Specified by:
getDocumentBase in interface AppletStub
Returns:
a "file:" URL for the current directory

getCodeBase

public final URL getCodeBase()
Gets the codebase URL.
Specified by:
getCodeBase in interface AppletStub
Returns:
in this case, the same value as getDocumentBase()

getParameter

public final String getParameter(String name)
Gets a parameter of the applet.
Specified by:
getParameter in interface AppletStub
Parameters:
name - the name of the parameter
Returns:
the value, or null if not defined

getAppletContext

public final AppletContext getAppletContext()
Gets a handler to the applet's context.
Specified by:
getAppletContext in interface AppletStub
Returns:
this object

appletResize

public void appletResize(int width,
                         int height)
Called when the applet wants to be resized. This causes the Frame (window) to be resized to accomodate the new Applet size.
Specified by:
appletResize in interface AppletStub
Parameters:
width - the new width of the applet
height - the new height of the applet

getAudioClip

public final AudioClip getAudioClip(URL url)
Gets an audio clip. (There doesn't seem to be a "Toolkit" for audio clips in my JDK, so this always returns null. You could implement this differently, returning a dummy AudioClip object for which the class could be defined at the bottom of this file.)
Specified by:
getAudioClip in interface AppletContext
Parameters:
url - URL of the AudioClip to load
Returns:
the AudioClip object if it exists (in our case, this is always null

getImage

public final Image getImage(URL url)
Gets an image. This usually involves downloading it over the net. However, the environment may decide to cache images. This method takes an array of URLs, each of which will be tried until the image is found.
Specified by:
getImage in interface AppletContext
Parameters:
url - URL of the Image to load
Returns:
the Image object

getApplet

public final Applet getApplet(String name)
Gets an applet by name.
Specified by:
getApplet in interface AppletContext
Parameters:
name - the name of the applet
Returns:
null if the applet does not exist, and it never does since we never name the applet.

getApplets

public final Enumeration getApplets()
Enumerates the applets in this context. Only applets that are accessible will be returned. This list always includes the applet itself.
Specified by:
getApplets in interface AppletContext
Returns:
the Enumeration -- contains ONLY the applet created with this DummyAppletContext

showDocument

public void showDocument(URL url)
Shows a new document. This may be ignored by the applet context (and in our case, it is, but we'll show the user, in the status area, that the document was requested and WOULD be loaded if in a browser).
Specified by:
showDocument in interface AppletContext
Parameters:
url - URL to load

showDocument

public void showDocument(URL url,
                         String target)
Show a new document in a target window or frame. This may be ignored by the applet context. (Again, it is ignored, but we'll show the request information to the user in the status area.) This method accepts the target strings: _self show in current frame _parent show in parent frame _top show in top-most frame _blank show in new unnamed top-level window show in new top-level window named
Specified by:
showDocument in interface AppletContext
Parameters:
url - URL to load
target - the target string

showStatus

public void showStatus(String text)
Show a status string in the status area (the Text object at the bottom of the window.
Specified by:
showStatus in interface AppletContext
Parameters:
text - the text to display

getStream

public InputStream getStream(String key)
Returns the stream to which specified key is associated within this applet context.
Specified by:
getStream in interface AppletContext

getStreamKeys

public Iterator getStreamKeys()
Finds all the keys of the streams in this applet context.
Specified by:
getStreamKeys in interface AppletContext

setStream

public void setStream(String key,
                      InputStream stream)
Associates the specified stream with the specified key in this applet context.
Specified by:
setStream in interface AppletContext




Copyright © 2005 SAS Institute Inc. All Rights Reserved.
javadoc generated Thu, 16 Feb 2006 02:30:21