|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--java.applet.Applet | +--javax.swing.JApplet | +--thegame.client.GameClient
The main class for the game client. Masters the connection to the server, the game and start screens. Provides some methods.
Inner Class Summary | |
protected class |
GameClient.GameScreen
The game screen. |
protected class |
GameClient.StartScreen
The start screen where the user can select a name and create or join a game. |
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 |
Inner classes inherited from class thegame.client.GameClientConstants |
GameClientConstants.GameScreenConstants, GameClientConstants.StartScreenConstants |
Field Summary | |
protected static GameClient |
applet
References the GameClient. |
protected GameClientConnection |
connection
The connection to the server. |
protected GameClient.GameScreen |
gameScreen
The game screen. |
protected java.lang.String |
host
The IP address of the server. |
protected boolean |
isAnApplet
Indicates whether the GameClient is running as an applet or as an application. |
protected java.lang.String |
localPlayerName
The name of the local player. |
protected java.lang.String[] |
mainArgs
Contains the command-line arguments passed to the GameClient in case it was run as an application. |
protected int |
port
The TCP port of the server. |
protected GameClient.StartScreen |
startScreen
The start screen. |
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 thegame.client.GameClientConstants |
HOST_PARAMETER_NAME, HOST_PARAMETER_NOT_FOUND_TEXT, NORMAL_TERMINATION_TEXT, PORT_PARAMETER_NAME, SERVER_SHUTDOWN_TEXT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
GameClient()
|
Method Summary | |
void |
bringUpGameScreen(boolean isLocalPlayerDrawingCircles,
boolean isConnectedToAPlayer,
java.lang.String remotePlayerName)
Empties the applet window and brings up a GameScreen. |
void |
bringUpStartScreen(boolean isPlayerAlreadyNamed)
Empties the applet window and brings up a StartScreen. |
void |
destroy()
Cleans up the data members that should be cleaned (connection to the server). |
void |
fatalError(java.lang.String message)
Shuts down the GameClient. |
static javax.swing.ImageIcon |
getImageIcon(java.lang.String path)
Returns an ImageIcon constructed from an image file. |
void |
handleMessage(java.lang.String message)
Based on the type identifier of the message, calls the needed methods from either StartScreen or GameScreen. |
void |
init()
Reads the required parameters, connects to the server and brings up a StartScreen. |
static void |
main(java.lang.String[] args)
Launches GameClient as an application. |
java.lang.String |
readParameter(java.lang.String parameterName)
Reads the required parameter from the applet HTML page source or, if GameClient is run as an application, from the commandline arguments. |
void |
readParameters()
Reads the HOST and PORT parameters from the applet HTML page source, or, if GameClient is run as an application, from the commandline arguments. |
void |
terminate()
Shuts down the GameClient. |
void |
tryAndSend(int id)
Calls send(int) from GameClientConnection. |
void |
tryAndSend(int id,
boolean body)
Calls send(int, boolean) from GameClientConnection. |
void |
tryAndSend(int id,
int[] body)
Calls send(int, int[][]) from GameClientConnection. |
void |
tryAndSend(int id,
int[][] body)
Calls send(int, int[][]) from GameClientConnection. |
void |
tryAndSend(int id,
java.lang.String body)
Calls send(int, String) from GameClientConnection. |
Methods inherited from class javax.swing.JApplet |
addImpl, createRootPane, 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 |
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 |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setFont, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, 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, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, 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, wait, wait, wait |
Field Detail |
protected static GameClient applet
protected GameClientConnection connection
protected GameClient.GameScreen gameScreen
protected java.lang.String host
protected boolean isAnApplet
protected java.lang.String localPlayerName
protected java.lang.String[] mainArgs
protected int port
protected GameClient.StartScreen startScreen
Constructor Detail |
public GameClient()
Method Detail |
public void bringUpGameScreen(boolean isLocalPlayerDrawingCircles, boolean isConnectedToAPlayer, java.lang.String remotePlayerName)
isLocalPlayerDrawingCircles
- true if the local player is drawing circles; false if the local player is drawing crossesisConnectedToAPlayer
- true if there is a remote player present; false otherwiseremotePlayerName
- the name of the remote player to be joined; or nullpublic void bringUpStartScreen(boolean isPlayerAlreadyNamed)
isPlayerAlreadyNamed
- true if the local player already has a name; false otherwisepublic void destroy()
destroy
in class java.applet.Applet
public void fatalError(java.lang.String message)
message
- the errormessage to be shownpublic static javax.swing.ImageIcon getImageIcon(java.lang.String path)
path
- the full path and filename of the image filepublic void handleMessage(java.lang.String message)
message
- the message to be handledpublic void init()
init
in class java.applet.Applet
public static void main(java.lang.String[] args)
args
- the command-line argumentspublic java.lang.String readParameter(java.lang.String parameterName)
parameterName
- the case-insensitive name of the parameterpublic void readParameters()
public void terminate()
public void tryAndSend(int id)
id
- the type identifier of the messagepublic void tryAndSend(int id, boolean body)
id
- the type identifier of the messagebody
- the body of the messagepublic void tryAndSend(int id, int[] body)
id
- the type identifier of the messagebody
- the body of the messagepublic void tryAndSend(int id, int[][] body)
id
- the type identifier of the messagebody
- the body of the messagepublic void tryAndSend(int id, java.lang.String body)
id
- the type identifier of the messagebody
- the body of the message
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |