Blackjack

com.amoebacode.blackjack
Class Blackjack

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--javax.swing.JApplet
                                |
                                +--com.amoebacode.blackjack.Blackjack
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable

public class Blackjack
extends javax.swing.JApplet

Blackjack is the main blackjack program that can be run as an applet or as an application.

Version:
0.9
Author:
Jason Gurney
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
 
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
private static java.lang.String APPLICATION_TITLE_BAR
          The title bar text used when the program is run as an application
private static java.lang.String BACKGROUND_IMAGE
          The path to the primary background image
private static java.lang.String BLANK_CARD_PATH
          The path to the blank card image (used for the backs of cards)
private static java.lang.String CARD_IMAGE_FILE_PREFIX
          The prefix for the relative path to the card image files
private static java.lang.String CARD_IMAGE_FILE_SUFFIX
          The suffix for the relative path to the card image file
private  boolean isApplication
          Indicates whether the program is run as an application
private static java.lang.String JAR
          The name of the parameter that indicates whether the applet is being run in a jar file
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.applet.Applet
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, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Blackjack()
          Default public empty constructor.
 
Method Summary
private  DisplayManager buildDisplayManager(java.awt.Container container)
          Builds and returns the UI manager that is used to display the game.
private  void buildGame(java.awt.Container container)
          Builds the UI and starts the game.
private  java.util.Map buildImages()
          Builds and returns a map of image icons used by the game.
private  java.util.Map buildSounds()
          Builds and returns a map of audio clips used by the game.
private  java.applet.AudioClip getAudioClip(java.lang.String audioPath)
          Retrieves the audio clip from the specified path.
private  javax.swing.ImageIcon getImage(java.lang.String imagePath)
          Retrieves the image from the specified path.
private  java.lang.String getImagePath(java.lang.String cardName)
          Returns the relative path of the image that corresponds to the specified card.
 void init()
          Initializes the applet.
private  boolean isNotJar()
          Indicates whether this applet is being run with a jar="false" parameter.
static void main(java.lang.String[] args)
          Command line runnable method for running program is an application.
private  void setIsApplication(boolean value)
          Sets whether the program is being run as an application.
private  void startGame(DisplayManager displayManager)
          Starts the game using the specified display manager.
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, createRootPaneException, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, 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, start, stop
 
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, paint, paintComponents, paintHeavyweightComponents, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, transferFocus, 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, 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

JAR

private static final java.lang.String JAR
The name of the parameter that indicates whether the applet is being run in a jar file

APPLICATION_TITLE_BAR

private static final java.lang.String APPLICATION_TITLE_BAR
The title bar text used when the program is run as an application

isApplication

private boolean isApplication
Indicates whether the program is run as an application

CARD_IMAGE_FILE_PREFIX

private static final java.lang.String CARD_IMAGE_FILE_PREFIX
The prefix for the relative path to the card image files

CARD_IMAGE_FILE_SUFFIX

private static final java.lang.String CARD_IMAGE_FILE_SUFFIX
The suffix for the relative path to the card image file

BLANK_CARD_PATH

private static final java.lang.String BLANK_CARD_PATH
The path to the blank card image (used for the backs of cards)

BACKGROUND_IMAGE

private static final java.lang.String BACKGROUND_IMAGE
The path to the primary background image
Constructor Detail

Blackjack

public Blackjack()
Default public empty constructor.
Method Detail

init

public void init()
Initializes the applet. (Method called by the browser or applet viewer when the applet has been loaded into the system.)
Overrides:
init in class java.applet.Applet

buildGame

private void buildGame(java.awt.Container container)
Builds the UI and starts the game.
Parameters:
container - the content pane for this applet/application

buildDisplayManager

private DisplayManager buildDisplayManager(java.awt.Container container)
Builds and returns the UI manager that is used to display the game.
Parameters:
container - the content pane for this applet/application
Returns:
the DisplayManager for the game

startGame

private void startGame(DisplayManager displayManager)
Starts the game using the specified display manager.
Parameters:
displayManager - the UI manager for the game

getImage

private javax.swing.ImageIcon getImage(java.lang.String imagePath)
Retrieves the image from the specified path. Uses one of three methods, depending on whether the program is being run as an application, as a standard applet, or as an applet through a jar file.
Parameters:
imagePath - the relative path to the image
Returns:
the corresponding Image

buildSounds

private java.util.Map buildSounds()
Builds and returns a map of audio clips used by the game.
Returns:
a Map of clips, indexed by their paths

buildImages

private java.util.Map buildImages()
Builds and returns a map of image icons used by the game.
Returns:
a Map of image icons, indexed by their names

getImagePath

private java.lang.String getImagePath(java.lang.String cardName)
Returns the relative path of the image that corresponds to the specified card.
Returns:
the image relative path

getAudioClip

private java.applet.AudioClip getAudioClip(java.lang.String audioPath)
Retrieves the audio clip from the specified path. Uses one of three methods, depending on whether the program is being run as an application, as a standard applet, or as an applet through a jar file.
Parameters:
audioPath - the relative path to the audio clip
Returns:
the corresponding AudioClip

isNotJar

private boolean isNotJar()
Indicates whether this applet is being run with a jar="false" parameter.
Returns:
true if the jar="false" parameter was set, false otherwise

setIsApplication

private void setIsApplication(boolean value)
Sets whether the program is being run as an application.
Parameters:
value - the new isApplication indicator

main

public static void main(java.lang.String[] args)
Command line runnable method for running program is an application.
Parameters:
args - the String array of command line arguments

Blackjack

Copyright © 2002 amoebacode.com.