wcs
Class Applet

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by wcs.Applet
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer

public class Applet
extends JApplet

backend for System spoofer. This is a singleton class to run main in a simulated terminal. As long as there is no static or explicit reference to System this will redirect standard i/o to and from a text area.

BUG: if a class relies on static initialization (e.g., static int x = 20;) and if the applet restarts execution, the initialization will not happen. One could call System.gc() and hope that this will cause the class to be reloaded on restart; however, if a class spawns a window and inserts itself as a listener, garbage collection is not going to reclaim things even after the main thread dies. How does one track and detach windows that a class creates (other then by closing the applet page)?

BUG (in Safari?): if a yydebug animation with standard i/o runs until end of file, Safari hangs. Before end of file the animation is interruptable as it should be. Check out release 2 of the 1.4.2 JDK...

The following parameters can be specified:

ea true enable assertions.
font.name Monospaced font in command line and standard i/o area.
font.size 12 font size command line and standard i/o area.
main white-space separated list of fully qualified class names to select for main.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JApplet
JApplet.AccessibleJApplet
 
Nested classes/interfaces inherited from class java.applet.Applet
Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected static ArrayList classes
          list of System spoofers.
protected  JTextField commandLine
          command line field.
protected  String commandLineText
          command line text.
protected static PrintStream err
          spoofs System.err.
protected static InputStream in
          spoofs System.in.
protected static int instances
          this is supposed to be a singleton.
protected  JComboBox mainClasses
          fully qualified main class name box.
protected static PrintStream out
          spoofs System.out.
protected  JButton startStop
          start/stop button.
protected  JTextArea textArea
          terminal screen.
protected  Thread thread
          client thread.
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
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
Applet()
           
 
Method Summary
protected  int getInteger(String key, int fallback)
          get a defaulted integer applet parameter value.
protected  String getString(String key, String fallback)
          get a defaulted applet string parameter value.
 void init()
          configure, establish control layer.
static void register(Class system)
          called from the static block of a System spoofer to initialize standard i/o, remembers the spoofer for future redirections.
 void run()
          (re)connect and (re)start execution.
 void running(boolean state)
          change running state.
static void setErr(PrintStream err)
          called by a System spoofer, posted to all known spoofers.
static void setIn(InputStream in)
          called by a System spoofer, posted to all known spoofers.
static void setOut(PrintStream out)
          called by a System spoofer, posted to all known spoofers.
 void start()
          delegate to running(boolean) depending on thread.
 void stop()
          close page, disconnect (and try to stop execution).
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

instances

protected static int instances
this is supposed to be a singleton.

See Also:
init()

in

protected static InputStream in
spoofs System.in.


out

protected static PrintStream out
spoofs System.out.


err

protected static PrintStream err
spoofs System.err.


classes

protected static final ArrayList classes
list of System spoofers.

See Also:
register(java.lang.Class), setIn(java.io.InputStream), setOut(java.io.PrintStream), setErr(java.io.PrintStream)

mainClasses

protected JComboBox mainClasses
fully qualified main class name box.


commandLine

protected JTextField commandLine
command line field.


commandLineText

protected String commandLineText
command line text.


startStop

protected JButton startStop
start/stop button.


textArea

protected JTextArea textArea
terminal screen.


thread

protected Thread thread
client thread. Invariant, monitored by this: if null, call run() to restart, else call stop() to stop.

Constructor Detail

Applet

public Applet()
Method Detail

register

public static void register(Class system)
called from the static block of a System spoofer to initialize standard i/o, remembers the spoofer for future redirections.


setIn

public static void setIn(InputStream in)
called by a System spoofer, posted to all known spoofers.


setOut

public static void setOut(PrintStream out)
called by a System spoofer, posted to all known spoofers.


setErr

public static void setErr(PrintStream err)
called by a System spoofer, posted to all known spoofers.


init

public void init()
configure, establish control layer. If this is not a singleton, there will be no active controls. This is called from the event thread only.

Overrides:
init in class Applet

start

public void start()
delegate to running(boolean) depending on thread.

Overrides:
start in class Applet

run

public void run()
(re)connect and (re)start execution. Create client body and start thread if possible; connection must exist first in case there are static references to System. This is called from the event thread only.


running

public void running(boolean state)
change running state. This is forced into the event thread if necessary.

Parameters:
state - true: starting main, false: stopping main.

stop

public void stop()
close page, disconnect (and try to stop execution).

Overrides:
stop in class Applet

getInteger

protected int getInteger(String key,
                         int fallback)
get a defaulted integer applet parameter value.


getString

protected String getString(String key,
                           String fallback)
get a defaulted applet string parameter value.