Class BaseApplet

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--BaseApplet
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.lang.Runnable, java.io.Serializable
Direct Known Subclasses:
BreadthFirstApplet

public class BaseApplet
extends java.applet.Applet
implements java.lang.Runnable, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

BaseApplet with methods intended to be over-ridden to create games, etc.

See Also:
Serialized Form

Field Summary
protected  java.awt.Color backgroundColor
           
protected  int currentDelay
           
protected  java.awt.Color foregroundColor
           
protected  java.awt.Image image
           
protected  java.lang.Thread myThread
           
protected  java.awt.Graphics offScreen
           
 
Fields inherited from class java.applet.Applet
 
Fields inherited from class java.awt.Panel
 
Fields inherited from class java.awt.Container
 
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
BaseApplet()
           
 
Method Summary
 void clearOffScreenBuffer()
          Clear the off-screen buffer.
 boolean continueRunning()
          Over-ride this in the derived class.
(package private)  void createOffScreenBuffer()
          Create the off-screen buffer.
 void init()
          Initialize the applet.
 void mouseClicked(java.awt.event.MouseEvent e)
          These are required for implementing MouseListener.
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
          These are required for implementing MouseMotionListener.
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paint(java.awt.Graphics g)
          paint(Graphics) is is called by update(Graphics).
(package private)  void paintBuffer()
          Paint the off-screen buffer onto the screen
 void run()
          Run the applet by running its thread.
 void setDelay(int delay)
          Set the current delay value in milliseconds.
 void sleep()
          Sleep for the amount specified in current delay.
 void sleep(int amount)
          Sleep for a specified number of milliseconds.
 void start()
          Start the applet.
 void step()
          Over-ride this in the derived class.
 void update(java.awt.Graphics g)
          update is implicitly called by repaint() It calls paint(Graphics).
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, stop
 
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, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, 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, 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, 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, isOpaque, 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, setName, 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

backgroundColor

protected java.awt.Color backgroundColor

foregroundColor

protected java.awt.Color foregroundColor

currentDelay

protected int currentDelay

myThread

protected java.lang.Thread myThread

image

protected java.awt.Image image

offScreen

protected java.awt.Graphics offScreen
Constructor Detail

BaseApplet

public BaseApplet()
Method Detail

init

public void init()
Initialize the applet. Can be over-ridden in a derived class, but if so, the over-riding method should call super.init();.

Overrides:
init in class java.applet.Applet

start

public void start()
Start the applet. Called when the applet is first started and when the web-page is re-entered.

Overrides:
start in class java.applet.Applet

run

public void run()
Run the applet by running its thread. This over-rides the run() method in class Applet.

Specified by:
run in interface java.lang.Runnable

sleep

public void sleep()
Sleep for the amount specified in current delay.


sleep

public void sleep(int amount)
Sleep for a specified number of milliseconds.


setDelay

public void setDelay(int delay)
Set the current delay value in milliseconds.


createOffScreenBuffer

void createOffScreenBuffer()
Create the off-screen buffer.


clearOffScreenBuffer

public void clearOffScreenBuffer()
Clear the off-screen buffer.


update

public void update(java.awt.Graphics g)
update is implicitly called by repaint() It calls paint(Graphics). This method intentionally over-rides update() in class Applet so that the background is not blanked, which will tend to cause flicker. It is probably best not to change this unless you really know what you are doing.

Overrides:
update in class java.awt.Container

paint

public void paint(java.awt.Graphics g)
paint(Graphics) is is called by update(Graphics). This is where the off-screen buffer gets painted to the screen. image contains the Graphics for what is to be painted. It is probably best not to change this unless you really know what you are doing.

Overrides:
paint in class java.awt.Container

continueRunning

public boolean continueRunning()
Over-ride this in the derived class. It gives the condition under which the applet will continue calling step in the main loop.


step

public void step()
Over-ride this in the derived class. It indicates what the will be done as a single step in the main loop.


paintBuffer

void paintBuffer()
Paint the off-screen buffer onto the screen


mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
These are required for implementing MouseListener. They can be over-ridden in a derived class at your option.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
These are required for implementing MouseMotionListener. They can be over-ridden in a derived class at your option.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener