GF4J 0.9.4 Beta

gameframe
Class ApplicationAppletBase

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--gameframe.ApplicationAppletBase
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.lang.Runnable, java.io.Serializable

public class ApplicationAppletBase
extends java.applet.Applet
implements java.lang.Runnable

Base class for a game that can act both as application and as an applet.

Since:
GameFrame for Java 0.9.4
Version:
GameFrame for Java 0.9.4
See Also:
Serialized Form

Inner classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
protected  java.lang.String[] m_args
          The arguments given to the program.
protected  boolean m_fApplet
          Whether the program is running as an applet (true) or application (false).
protected  boolean m_fInitialized
          Whether the program is properly initialized or not.
protected  boolean m_fRunning
          True when applet/application should be running, false when it should exit.
protected  java.lang.Thread m_thread
          The thread use to run the applet/application.
 
Fields inherited from class java.applet.Applet
accessibleContext, serialVersionUID, stub
 
Fields inherited from class java.awt.Panel
base, nameCounter
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dbg, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, width, windowClosingException, windowListenerK, visible, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ApplicationAppletBase()
          Constructs the example Applet.
ApplicationAppletBase(java.lang.String[] args)
          Constructs the example application and stores the command line arguments given.
 
Method Summary
private  boolean checkLibrary()
          Checks if the library is installed or not.
 void destroy()
          Closes and cleans up after applet/application.
 void init()
          Initializes the GameFrame for Java library.
static void main(java.lang.String[] args)
          Starts up the example application (creates an instance and calls the init() and start() methods of the instance).
protected  void mainLoop()
          The method where the game should be executed while flag m_fRunning is true.
 void paint(java.awt.Graphics grfx)
          Overridden to display a text message when the applet has stopped execution (user presses ESC etc.)
protected  void printToConsole(java.lang.String strText)
          Prints the given message to the console (even on browsers).
 void run()
          Executes the example applet/application
protected  void setGameFrameSettings(GameFrameSettings gameFrameSettings)
          Sets the GameFrame settings to the given settings object.
 void start()
          Starts the applet/application running.
 void stop()
          Stops the applets/applications running.
 
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, constructComponentName
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, adjustListeningChildren, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocus, numListening, paintComponents, paintHeavyweightComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, setLayout, transferFocus, update, validate, validateTree, writeObject
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

m_thread

protected java.lang.Thread m_thread
The thread use to run the applet/application.

m_fApplet

protected boolean m_fApplet
Whether the program is running as an applet (true) or application (false).

m_fInitialized

protected boolean m_fInitialized
Whether the program is properly initialized or not.

m_fRunning

protected boolean m_fRunning
True when applet/application should be running, false when it should exit.

m_args

protected java.lang.String[] m_args
The arguments given to the program.
Constructor Detail

ApplicationAppletBase

public ApplicationAppletBase(java.lang.String[] args)
Constructs the example application and stores the command line arguments given. This method is called when the program is ran as a stand alone application.
Parameters:
args - The command line arguments given.

ApplicationAppletBase

public ApplicationAppletBase()
Constructs the example Applet. This is used when running the program as an Applet.
Method Detail

main

public static void main(java.lang.String[] args)
Starts up the example application (creates an instance and calls the init() and start() methods of the instance).

init

public void init()
Initializes the GameFrame for Java library. Subclasses can override this to initialize themselves (but remember to say "super.init()" as the first statement in the overriding init() method).
Overrides:
init in class java.applet.Applet

setGameFrameSettings

protected void setGameFrameSettings(GameFrameSettings gameFrameSettings)
Sets the GameFrame settings to the given settings object. Subclasses must implement this method and set the wanted settings to the settings object.
Parameters:
gameFrameSettings - The settings object to be configured.

start

public void start()
Starts the applet/application running.
Overrides:
start in class java.applet.Applet

run

public void run()
Executes the example applet/application
Specified by:
run in interface java.lang.Runnable

paint

public void paint(java.awt.Graphics grfx)
Overridden to display a text message when the applet has stopped execution (user presses ESC etc.)
Overrides:
paint in class java.awt.Container
Parameters:
grfx - The graphics context to draw to.

stop

public void stop()
Stops the applets/applications running.
Overrides:
stop in class java.applet.Applet

destroy

public void destroy()
Closes and cleans up after applet/application.
Overrides:
destroy in class java.applet.Applet

mainLoop

protected void mainLoop()
The method where the game should be executed while flag m_fRunning is true. When this method exits, the applet/application will stop/exit.

checkLibrary

private boolean checkLibrary()
Checks if the library is installed or not. If not shows an error.
Returns:
True if the library is installed, false if not.

printToConsole

protected void printToConsole(java.lang.String strText)
Prints the given message to the console (even on browsers).
Parameters:
strText - The message to be shown.

GF4J 0.9.4 Beta