|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
javax.swing.JApplet
main.EangTermProject
public class EangTermProject
Created on October 27, 2006, 6:01 PM
The main frame for the othello applet.
Sets up the menus and the game board. Also designed to run as a stand alone application.
Refactored: removed the cell array into a seperate panel.
Changed the current player panel to a more specific panel to display additional information not included in the basic othello cell, such as a string "Current player = White"
t.5 Made changes to work with changes in communications.
t.6 added control for the sound by adding a sound on menu item checkbox.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JApplet |
|---|
javax.swing.JApplet.AccessibleJApplet |
| 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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary |
|---|
| 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 java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
EangTermProject()
Creates a new instance of EangTermProject |
|
| Method Summary | |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent aevnt)
Handles menu actions, such as start. |
void |
configHosting()
Prompts the user to configure settings for hosting a game. |
void |
countPieces()
Counts the pieces on the board and updates the score. |
void |
createConnectSplash(java.lang.String data)
Creates a splash that is used while either hosting and waiting or while connecting to a remote host. |
void |
determineColor(java.lang.String data)
Determine the players colors. Called when the host recieves a message to set up the colors. Parses the message for the number chosen by the opponent, then compares it to a number chosen by the host. |
void |
disconnect()
Disconnects from a networked game. Resets the menus and displays the original intro splash screen. |
void |
disconnectMessage()
Displays a message if there was a problem with the network connection. |
void |
doConnection(java.lang.String connectString)
Attempts to connect to a remote host given the settings to be used. |
void |
endGame()
Ends the game. Displays a splash panel indicating the outcome of the game. |
void |
getMyColor()
Gets the color of the player playing on this board. Sends a request to the host asking for this players color. |
java.lang.String |
getOpponnentColor()
Gets the opponents color. |
java.lang.String |
getPlayer()
Gets the players color. |
void |
init()
Initializes the applet. |
void |
initBoard()
Initializes the gameboard and adds the cells to the panel. |
void |
initIntroSplash()
Initializes the splash for the intro, when the game is started. |
void |
initMenu()
Sets up the menu. |
void |
initNetMenu()
Initializes the network menu. |
void |
initPlayerSquare()
Creates and adds the current player panel. |
void |
initScoreSquare()
Creates and adds the player score panel. |
void |
iPlacedPiece()
Updates the gameboard after a piece is successfully placed on the board. |
boolean |
isWaitingForColor()
Gets whether the game is still waiting for the player color to be set. |
static void |
main(java.lang.String[] args)
The main function that starts the appilication. |
void |
menuCanceled(javax.swing.event.MenuEvent mevent)
Handles menu canceled events. |
void |
menuDeselected(javax.swing.event.MenuEvent mevent)
Sets the games pause state to the original pause state. |
void |
menuSelected(javax.swing.event.MenuEvent mevent)
Pauses the game when a menu is clicked. |
void |
moveEnemy(java.lang.String enemyPosition)
Moves the enemy. Updates the enemies position if over a valid move. |
void |
newGame()
Starts a new game. First tries to remove and stop any existing panels and threads. Next it recreates the game board and loads the images and initializes the score and current player panels. |
void |
pauseGame(boolean pg)
Changes the pause state of the game. |
boolean |
placeEnemy(java.lang.String enemyPosition)
Places an enemy/opponent's piece on the game board. |
void |
removeComms()
removes the comms panel from the main panel. |
void |
removeCurrentPlayer()
removes the currentPlayer panel from the main panel. |
void |
removeGameBoard()
removes the gameBoard panel from the main panel. |
void |
removeIntro()
Removes the intro panel from the main panel. |
void |
removeScore()
removes the scorePanel from the main panel. |
void |
resetBackground()
Resets the backgrounds on the game board after a move is made or a piece is placed. |
void |
resetCurrentPlayer()
Resets the current player color. |
void |
sendOpponnentColor()
Sends the opponents color when requested. |
void |
sendPlacedPiece(java.awt.Point myPosition)
Sends the point when a piece is placed on the board. |
void |
sendPosition(java.awt.Point myPosition)
Sends the position when the mouse is over a valid move. |
void |
setActivePlayer()
Sets the current active player. Prevents the game board from recieving events if the player is not the players turn. |
void |
setBoardCheck()
USED FOR DEBUGGING. Used to test a possible case when the mouse listeners are not correctly reset. |
void |
setBoardSkip()
USED FOR DEBUGGING. Used to force the white player to have to skip a turn. |
void |
setCommsConnected(boolean connected)
Sets the comms connection state. |
void |
setCurrentPlayer()
Sets the current player color that is placing a piece on the board. |
void |
setPanelsVisible(boolean vis)
Hides the panels so they do not overlap the splash panel. |
void |
setPlayer(java.lang.String player)
Sets the player color Also sets the player color on the Score panel, but only if playing a networked game. |
void |
setPlayerColor(java.lang.String data)
Sets the players color. |
void |
setUpColor()
Sets up the color when playing a network game. This is only done by the player connecting to the host. |
void |
setUpConnection()
Prompts the user for the connection settings when playing a networked game. |
void |
setWaitingForColor(boolean waitingForColor)
Sets if still waiting for the player's color or not. |
void |
startHosting(java.lang.String connectString)
Starts up a network socket to wait for a connection. |
boolean |
stillValidMoves()
Checks to see if there are still any valid moves. If the current player does not have any valid moves, then a message is displayed and their turn is skipped. |
void |
stop()
Stops the game. Attempts to stop all threads that are currently running. |
void |
stopComms()
Stops the communications if the comms thread is not null. |
void |
stopCurrentPlayer()
Stops the current player panel thread if it is not null. |
void |
stopCurrentScore()
Stops the current score panel thread if it is not null. |
void |
stopGameBoard()
Stops the game board if it is not null. |
void |
stopIntro()
Stops the splash thread if it is not null. |
void |
turnSound(boolean soundState)
Changes the sound state when the sound menu check box item is clicked. |
void |
updateConnect(java.lang.String updateWith)
Updates the comms splash panel with a new string. |
void |
windowActivated(java.awt.event.WindowEvent we)
Handles the window activated event. |
void |
windowClosed(java.awt.event.WindowEvent we)
Handles the window closed event. |
void |
windowClosing(java.awt.event.WindowEvent we)
Handles the window closed event. Stops all threads and disposes of the panels. |
void |
windowDeactivated(java.awt.event.WindowEvent we)
Handles the windows deactivated event. |
void |
windowDeiconified(java.awt.event.WindowEvent we)
Handles the window deiconified event. |
void |
windowIconified(java.awt.event.WindowEvent we)
Handles the window iconified event. |
void |
windowOpened(java.awt.event.WindowEvent we)
Handles the window opened event. |
| Methods inherited from class javax.swing.JApplet |
|---|
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, 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 |
| Methods inherited from class java.awt.Panel |
|---|
addNotify |
| Methods inherited from class java.awt.Container |
|---|
add, add, add, add, add, addContainerListener, 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, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, firePropertyChange, firePropertyChange, firePropertyChange, 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, 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 |
| Constructor Detail |
|---|
public EangTermProject()
| Method Detail |
|---|
public void init()
init in class java.applet.Appletpublic void initMenu()
public void initNetMenu()
public void initIntroSplash()
public void initBoard()
public void initScoreSquare()
public void initPlayerSquare()
public void pauseGame(boolean pg)
pg - The new pause state of the game.public void stop()
stop in class java.applet.Appletpublic void stopGameBoard()
public void stopCurrentPlayer()
public void stopCurrentScore()
public void stopComms()
public void stopIntro()
public void disconnect()
public void disconnectMessage()
public void createConnectSplash(java.lang.String data)
data - The string to be displayed in the splash panel.public void removeIntro()
public void removeGameBoard()
public void removeCurrentPlayer()
public void removeScore()
public void removeComms()
public void newGame()
public void endGame()
public void setCurrentPlayer()
public void resetCurrentPlayer()
public void countPieces()
public boolean stillValidMoves()
public void setPanelsVisible(boolean vis)
vis - Whether the panels are visible or not.public void configHosting()
public void startHosting(java.lang.String connectString)
connectString - The string containing setup information for the comms configuration.public void updateConnect(java.lang.String updateWith)
updateWith - The string to update the splash panel with.public void setUpConnection()
public void doConnection(java.lang.String connectString)
connectString - A string containing the settings to be used when trying to connect to a remote host.public void sendPosition(java.awt.Point myPosition)
myPosition - A point representig the current position overpublic void sendPlacedPiece(java.awt.Point myPosition)
myPosition - The point of the piece placed on the board.public void setUpColor()
public void determineColor(java.lang.String data)
data - A string containing the number chosen by the opponent, ie the player connecting to the host.public void getMyColor()
public void sendOpponnentColor()
public java.lang.String getOpponnentColor()
public void setPlayerColor(java.lang.String data)
data - The new player's color.public void setCommsConnected(boolean connected)
connected - Whether comms is connected or not.public void iPlacedPiece()
public void setPlayer(java.lang.String player)
player - The player's color.public java.lang.String getPlayer()
public void resetBackground()
public void setActivePlayer()
public void moveEnemy(java.lang.String enemyPosition)
enemyPosition - The enemies new position.public boolean placeEnemy(java.lang.String enemyPosition)
enemyPosition - The position the enemy placed a piece.
public void turnSound(boolean soundState)
soundState - The new sound state.public void menuCanceled(javax.swing.event.MenuEvent mevent)
menuCanceled in interface javax.swing.event.MenuListenermevent - The menu event canceled.public void menuSelected(javax.swing.event.MenuEvent mevent)
menuSelected in interface javax.swing.event.MenuListenermevent - The menu selected.public void menuDeselected(javax.swing.event.MenuEvent mevent)
menuDeselected in interface javax.swing.event.MenuListenermevent - The menu unselcted.public void actionPerformed(java.awt.event.ActionEvent aevnt)
actionPerformed in interface java.awt.event.ActionListeneraevnt - The event fired.public void setBoardSkip()
public void setBoardCheck()
public void windowDeactivated(java.awt.event.WindowEvent we)
windowDeactivated in interface java.awt.event.WindowListenerwe - The window event.public void windowActivated(java.awt.event.WindowEvent we)
windowActivated in interface java.awt.event.WindowListenerwe - The source of the window event.public void windowDeiconified(java.awt.event.WindowEvent we)
windowDeiconified in interface java.awt.event.WindowListenerwe - The source of the window event.public void windowIconified(java.awt.event.WindowEvent we)
windowIconified in interface java.awt.event.WindowListenerwe - The source of the window event.public void windowClosing(java.awt.event.WindowEvent we)
windowClosing in interface java.awt.event.WindowListenerwe - The source of the window event.public void windowClosed(java.awt.event.WindowEvent we)
windowClosed in interface java.awt.event.WindowListenerwe - The source of the window event.public void windowOpened(java.awt.event.WindowEvent we)
windowOpened in interface java.awt.event.WindowListenerwe - The source of the window event.public boolean isWaitingForColor()
public void setWaitingForColor(boolean waitingForColor)
waitingForColor - True if still waiting, false otherwise.public static void main(java.lang.String[] args)
args - An array of arguments passed into main.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||