org.jrabbit.standard.game.main
Class StandardApplet

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 org.jrabbit.standard.game.main.StandardApplet
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public abstract class StandardApplet
extends java.applet.Applet

This very minimal class is all that is needed for a jRabbit game to run in an Applet. One of the design goals of the Java Rabbit Engine is that it should be extremely easy for the developer to have their game run as either an applet or as a standalone application, with as little difference in code as possible. This has been achieved by letting an Applet basically act as a "wrapper" around a game base on StandardGame, enabling the game to run in a browser with as few lines of code as possible. To do this, when extend StandardApplet's run command and have it create a new instance of the StandardGame in question and call run on it.

Author:
Chris Molini
See Also:
Serialized Form

Nested Class Summary
protected  class StandardApplet.AppletGameThread
          AppletGameThread manages the main game separately from the Applet's initialization thread.
 
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.awt.Canvas canvas
          The canvas upon which the Display will be drawn.
protected  boolean gameStarted
          Whether or not the game has been started.
protected  StandardApplet.AppletGameThread gameThread
          The Thread in which the game is updated and rendered.
private static long serialVersionUID
          The serialization ID.
 
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
StandardApplet()
           
 
Method Summary
 void destroy()
          Signals the main game for destruction, then waits for it to finish.
protected abstract  void exitGame()
          This is called whenever the applet is destroyed.
 void init()
          This base Applet, setting the stage for the game to run.
protected abstract  void pauseGame()
          This is called whenever the page the applet is on is left (i.e., the browser goes to another page or tab).
protected abstract  void resumeGame()
          This is called whenever the page the applet is on is made active (i.e., the browser goes to it from another page or tab).
 void start()
          If the game has not been started yet, this initializes it.
protected abstract  void startGame()
          This is the method called to run the applet.
 void stop()
          Signals the main game that it should pause.
 
Methods inherited from class java.applet.Applet
getAccessibleContext, 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, addImpl, 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, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, 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

serialVersionUID

private static final long serialVersionUID
The serialization ID.

See Also:
Constant Field Values

gameStarted

protected boolean gameStarted
Whether or not the game has been started.


canvas

protected java.awt.Canvas canvas
The canvas upon which the Display will be drawn.


gameThread

protected StandardApplet.AppletGameThread gameThread
The Thread in which the game is updated and rendered.

Constructor Detail

StandardApplet

public StandardApplet()
Method Detail

init

public final void init()
This base Applet, setting the stage for the game to run.

Overrides:
init in class java.applet.Applet

start

public void start()
If the game has not been started yet, this initializes it. Otherwise, this tells the main game to resume.

Overrides:
start in class java.applet.Applet

stop

public void stop()
Signals the main game that it should pause.

Overrides:
stop in class java.applet.Applet

destroy

public void destroy()
Signals the main game for destruction, then waits for it to finish.

Overrides:
destroy in class java.applet.Applet

startGame

protected abstract void startGame()
This is the method called to run the applet. Initialize the game here.


pauseGame

protected abstract void pauseGame()
This is called whenever the page the applet is on is left (i.e., the browser goes to another page or tab). It is intended to pause the game.


resumeGame

protected abstract void resumeGame()
This is called whenever the page the applet is on is made active (i.e., the browser goes to it from another page or tab). It is intended to resume the game after being paused.


exitGame

protected abstract void exitGame()
This is called whenever the applet is destroyed. Use it to signal the main game that it should exit.