thegame.client
Class GameClient.GameScreen

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--thegame.client.GameClient.GameScreen
All Implemented Interfaces:
javax.accessibility.Accessible, GameClientConstants.GameScreenConstants, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Enclosing class:
GameClient

protected class GameClient.GameScreen
extends javax.swing.JPanel
implements GameClientConstants.GameScreenConstants

The game screen.

Version:
0.99 (2000/08/28)
Author:
Erki Suurjaak
See Also:
Serialized Form

Inner Class Summary
protected  class GameClient.GameScreen.Monitor
          Is used for counting the elapsed turn time of the active player; also for checking whether the local player has made a move.
 
Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  javax.swing.JButton[] allButtons
          References all the buttons.
protected  java.awt.event.ActionListener[] BUTTON_ACTION_LISTENERS
          References ActionListeners that will be set to the buttons.
protected  java.awt.event.ItemListener[] CHECK_BOX_ITEM_LISTENERS
          References ItemListeners that will be set to the checkboxes.
protected  javax.swing.JCheckBox[] checkBoxes
          References all the checkboxes.
protected  javax.swing.JTextField enterMessageField
          Accepts a message that can be sent to the remote player.
protected  javax.swing.JLabel enterMessageFieldLabel
          The label for enterMessageField.
protected  GameField gameField
          The gamefield.
protected  javax.swing.JButton[] gameRunningButtons
          References buttons that are enabled only when a game is running.
protected  javax.swing.JButton[] gameStateButtons
          References buttons that are grouped together.
protected  boolean isConnectedToAPlayer
          True if the player is connected to a remote player; false otherwise.
protected  boolean isGameRunning
          True if a game is running; false otherwise.
protected  boolean isLocalPlayerMove
          True if it's the local player's turn; false otherwise.
protected  boolean isRequestingForANewGame
          True if the local player has sent a request for a new game to the remote player; false otherwise.
protected  javax.swing.JLabel localPlayerCurrentTimeLabel
          Shows the duration of the local player's current turn or of the previous turn if it is not the local player's turn.
protected  javax.swing.ImageIcon localPlayerHighlightedImageIcon
          The icon contains the highlighted version of the symbol the local player makes (a cross or a circle).
protected  javax.swing.JLabel localPlayerIcon
          Holds the icon for the local player.
protected  javax.swing.ImageIcon localPlayerImageIcon
          The icon contains the symbol the local player makes (a cross or a circle).
protected  javax.swing.JLabel[] localPlayerLabels
          References labels that hold information about the local player.
protected  javax.swing.JLabel localPlayerNameLabel
          Shows the name of the local player.
protected  javax.swing.JLabel localPlayerOverallTimeLabel
          Shows the duration of the local player's moves during the current game or the previous game if a new game has not been started yet.
protected  int localPlayerScore
          The score of the local player.
protected  javax.swing.JLabel localPlayerScoreLabel
          Shows the score of the local player.
protected  javax.swing.JTextArea messageArea
          Holds the messages that have been sent between the players.
protected  GameClient.GameScreen.Monitor monitor
          Handles local player moves and updates the time counts.
protected  java.awt.event.ActionListener ON_CLEAR_MESSAGE_AREA_BUTTON_CLICK
          The event handler for the "Clear" button.
protected  java.awt.event.ActionListener ON_NEW_GAME_BUTTON_CLICK
          The event handler for the "New game" button.
protected  java.awt.event.ActionListener ON_QUIT_GAME_BUTTON_CLICK
          The event handler for the "Quit game" button.
protected  java.awt.event.ActionListener ON_QUIT_TO_START_SCREEN_BUTTON_CLICK
          The event handler for the "Return to start screen" button.
protected  java.awt.event.ActionListener ON_SEND_MESSAGE_BUTTON_CLICK
          The event handler for the "Send" button.
protected  java.awt.event.ItemListener ON_SHOW_LOCAL_PLAYER_LAST_MOVE_CHECK_BOX_CLICK
          The event handler for the "Show my last move" checkbox.
protected  java.awt.event.ItemListener ON_SHOW_REMOTE_PLAYER_LAST_MOVE_CHECK_BOX_CLICK
          The event handler for the "Show remote player's last move" checkbox.
protected  java.awt.event.ActionListener ON_SURRENDER_GAME_BUTTON_CLICK
          The event handler for the "Surrender" button.
protected  java.awt.event.ActionListener ON_WAIT_FOR_NEW_PLAYER_BUTTON_CLICK
          The event handler for the "Wait for new player" button.
protected  javax.swing.JLabel overallTimeLabel
          Shows the duration of the game in progress or of the previous game if a new one has not been started yet.
protected  javax.swing.JButton[] playerExistsButtons
          References buttons that are enabled only when a remote player is present.
protected  javax.swing.JLabel[] playerNameLabels
          References labels that show the names of the players.
protected  javax.swing.JLabel[] playerScoreLabels
          References labels that show the scores of the players.
protected  javax.swing.JLabel[] playerTimeLabels
          References labels that show the times of the players.
protected  javax.swing.JLabel remotePlayerCurrentTimeLabel
          Shows the duration of the remote player's current turn or of the previous turn if it is not the remote player's turn.
protected  javax.swing.ImageIcon remotePlayerHighlightedImageIcon
          The icon contains the highlighted version of the symbol the remote player makes (a cross or a circle).
protected  javax.swing.JLabel remotePlayerIcon
          Holds the icon for the remote player.
protected  javax.swing.ImageIcon remotePlayerImageIcon
          The icon contains the symbol the remote player makes (a cross or a circle).
protected  javax.swing.JLabel[] remotePlayerLabels
          References labels that hold information about the remote player.
protected  java.lang.String remotePlayerName
          The name of the remote player.
protected  javax.swing.JLabel remotePlayerNameLabel
          Shows the name of the remote player or "(NO PLAYER)" if no remote player has not joined yet or, if the remote player quit, the name of the remote player plus " (QUIT)".
protected  javax.swing.JLabel remotePlayerOverallTimeLabel
          Shows the duration of the remote player's moves during the current game or the previous game if a new game has not been started yet.
protected  int remotePlayerScore
          The score of the remote player.
protected  javax.swing.JLabel remotePlayerScoreLabel
          Shows the score of the remote player.
protected  java.text.SimpleDateFormat timeFormatter
          Is used to convert a time in milliseconds into a HH:mm:ss format.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface thegame.client.GameClientConstants.GameScreenConstants
BUTTON_INSETS, BUTTON_LABELS, BUTTON_MNEMONICS, BUTTON_PANEL_COLS, BUTTON_PANEL_HEIGHT, BUTTON_PANEL_ROWS, BUTTON_PANEL_WIDTH, BUTTON_TOOL_TIPS, CHECK_BOX_INSETS, CHECK_BOX_LABELS, CHECK_BOX_MNEMONICS, CHECK_BOX_PANEL_COLS, CHECK_BOX_PANEL_ROWS, CHECK_BOX_TOOL_TIPS, CHECK_BOXES_FONT, CLEAR_MESSAGE_AREA_BUTTON_NUMBER, CLEAR_MESSAGE_AREA_LABEL, CLEAR_MESSAGE_AREA_MNEMONIC, CLEAR_MESSAGE_AREA_TOOL_TIP, ENTER_MESSAGE_FIELD_LABEL_LABEL, GAME_RUNNING_BUTTONS, GAME_STATE_BUTTONS, MESSAGE_AREA_COLS, MESSAGE_AREA_INSETS, MESSAGE_AREA_LABEL, MESSAGE_AREA_MAXIMUM_LENGTH, MESSAGE_AREA_ROWS, NEW_GAME_BUTTON_CLICK_MESSAGE_TEXT, NEW_GAME_BUTTON_CLICK_MESSAGE_TITLE, NEW_GAME_BUTTON_LABEL, NEW_GAME_BUTTON_MNEMONIC, NEW_GAME_BUTTON_NUMBER, NEW_GAME_BUTTON_TOOL_TIP, NEW_LINE, NEW_PLAYER_MESSAGE_TEXT, NEW_PLAYER_MESSAGE_TITLE, NUMBER_OF_BUTTONS, NUMBER_OF_CHECK_BOXES, NUMBER_OF_GAME_RUNNING_BUTTONS, NUMBER_OF_GAME_STATE_BUTTONS, NUMBER_OF_PLAYER_EXISTS_BUTTONS, PLAYER_ACCEPTED_NEW_GAME_MESSAGE_TEXT, PLAYER_ACCEPTED_NEW_GAME_MESSAGE_TITLE, PLAYER_CIRCLED_ICON, PLAYER_CIRCLED_ICON_PATH, PLAYER_CROSSED_ICON, PLAYER_CROSSED_ICON_PATH, PLAYER_DROPPED_MESSAGE_TEXT, PLAYER_DROPPED_MESSAGE_TITLE, PLAYER_EXISTS_BUTTONS, PLAYER_HIGHLIGHTED_CIRCLED_ICON, PLAYER_HIGHLIGHTED_CIRCLED_ICON_PATH, PLAYER_HIGHLIGHTED_CROSSED_ICON, PLAYER_HIGHLIGHTED_CROSSED_ICON_PATH, PLAYER_LABELS_FONT, PLAYER_LABELS_PANEL_COLS, PLAYER_LABELS_PANEL_ROWS, PLAYER_LOST_MESSAGE_TEXT, PLAYER_LOST_MESSAGE_TITLE, PLAYER_QUIT_MESSAGE_TEXT, PLAYER_QUIT_MESSAGE_TITLE, PLAYER_QUIT_TO_START_SCREEN_MESSAGE_TEXT, PLAYER_QUIT_TO_START_SCREEN_MESSAGE_TITLE, PLAYER_REFUSED_NEW_GAME_MESSAGE_TEXT, PLAYER_REFUSED_NEW_GAME_MESSAGE_TITLE, PLAYER_REQUESTED_NEW_GAME_MESSAGE_TEXT, PLAYER_REQUESTED_NEW_GAME_MESSAGE_TITLE, PLAYER_SCORE_LABELS_FONT, PLAYER_SURRENDERED_MESSAGE_TEXT, PLAYER_SURRENDERED_MESSAGE_TITLE, PLAYER_WON_MESSAGE_TEXT, PLAYER_WON_MESSAGE_TITLE, QUIT_GAME_BUTTON_CLICK_MESSAGE_TEXT, QUIT_GAME_BUTTON_CLICK_MESSAGE_TITLE, QUIT_GAME_BUTTON_LABEL, QUIT_GAME_BUTTON_MNEMONIC, QUIT_GAME_BUTTON_TOOL_TIP, QUIT_TO_START_SCREEN_BUTTON_CLICK_MESSAGE_TEXT, QUIT_TO_START_SCREEN_BUTTON_CLICK_MESSAGE_TITLE, QUIT_TO_START_SCREEN_BUTTON_LABEL, QUIT_TO_START_SCREEN_BUTTON_MNEMONIC, QUIT_TO_START_SCREEN_BUTTON_TOOL_TIP, REMOTE_PLAYER_START_LABEL, SCORE_START_LABEL, SEND_MESSAGE_AREA_COLS, SEND_MESSAGE_AREA_LABEL, SEND_MESSAGE_BUTTON_INSETS, SEND_MESSAGE_BUTTON_LABEL, SEND_MESSAGE_BUTTON_LABEL_MNEMONIC, SEND_MESSAGE_BUTTON_MNEMONIC, SEND_MESSAGE_BUTTON_NUMBER, SEND_MESSAGE_BUTTON_TOOL_TIP, SEND_MESSAGE_PANEL_COLS, SHOW_LOCAL_PLAYER_LAST_MOVE_CHECK_BOX_LABEL, SHOW_LOCAL_PLAYER_LAST_MOVE_CHECK_BOX_MNEMONIC, SHOW_LOCAL_PLAYER_LAST_MOVE_CHECK_BOX_TOOL_TIP, SHOW_REMOTE_PLAYER_LAST_MOVE_CHECK_BOX_LABEL, SHOW_REMOTE_PLAYER_LAST_MOVE_CHECK_BOX_MNEMONIC, SHOW_REMOTE_PLAYER_LAST_MOVE_CHECK_BOX_TOOL_TIP, SURRENDER_GAME_BUTTON_CLICK_MESSAGE_TEXT, SURRENDER_GAME_BUTTON_CLICK_MESSAGE_TITLE, SURRENDER_GAME_BUTTON_LABEL, SURRENDER_GAME_BUTTON_MNEMONIC, SURRENDER_GAME_BUTTON_NUMBER, SURRENDER_GAME_BUTTON_TOOL_TIP, TIME_START_LABEL, WAIT_FOR_NEW_PLAYER_BUTTON_CLICK_MESSAGE_TEXT, WAIT_FOR_NEW_PLAYER_BUTTON_CLICK_MESSAGE_TITLE, WAIT_FOR_NEW_PLAYER_BUTTON_LABEL, WAIT_FOR_NEW_PLAYER_BUTTON_MNEMONIC, WAIT_FOR_NEW_PLAYER_BUTTON_TOOL_TIP
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GameClient.GameScreen(boolean isLocalPlayerDrawingCircles, boolean isConnectedToAPlayer, java.lang.String remotePlayerName)
          Constructs a GameScreen.
 
Method Summary
 void addLocalPlayerMessageToMessageArea(java.lang.String toBeAdded)
          Adds toBeAdded with the local player name and current time to messageArea.
 void addRemotePlayerMessageToMessageArea(java.lang.String toBeAdded)
          Adds toBeAdded with the remote player name and current time to messageArea.
 void addTextToMessageArea(java.lang.String toBeAdded)
          Adds toBeAdded to messageArea.
 void changePlayerHighlight(boolean highlightLocalPlayer)
          Changes the highlight of players - sets one highlighted and the other unhighlighted.
 void handleMoveMadeMessage(int[] square)
          Handles a message from the server indicating that the remote player made a move.
 void handleNewGameAcceptedMessage()
          Handles a message from the server indicating that the remote player accepted a new game.
 void handleNewGameRefusedMessage()
          Handles a message from the server indicating that the remote player refused a new game.
 void handleNewGameRequestedMessage()
          Handles a message from the server indicating that the remote player requested for a new game.
 void handlePlayerDroppedMessage()
          Handles a message from the server indicating that the remote player dropped the local player.
 void handlePlayerJoinedMessage(java.lang.String playerName)
          Handles a message from the server indicating that a remote player joined the game.
 void handlePlayerQuitMessage()
          Handles a message from the server indicating that the remote player quit.
 void handlePlayerReturnedToStartScreenMessage()
          Handles a message from the server indicating that the remote player returned to start screen.
 void handlePlayerSurrenderedMessage()
          Handles a message from the server indicating that the remote player surrenderer.
 void handleTextMessage(java.lang.String message)
          Handles a message from the server indicating that the remote player sent a message.
 void handleWinningMoveMadeMessage(int[][] squares)
          Handles a message from the server indicating that the remote player made a winning move.
 void increaseLocalPlayerScore()
          Increases the local player's score and updates the interface.
 void increaseRemotePlayerScore()
          Increases the remote player's score and updates the interface.
 void setInterfaceToGameOverMode(boolean isGameOver)
          Sets the interface to game over mode or game running mode.
 void setInterfaceToLocalPlayerMoveMode(boolean interfaceToLocalPlayerMoveMode)
          Changes the interface to reflect whose move it is.
 void setNeededComponentsEnabled(boolean enabled)
          Sets certain predetermined components enabled or disabled.
 void setPlayerIconsUnhighlighted()
          Unhighlights the player icons.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getWidth, getVisibleRect, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

allButtons

protected javax.swing.JButton[] allButtons
References all the buttons.

BUTTON_ACTION_LISTENERS

protected java.awt.event.ActionListener[] BUTTON_ACTION_LISTENERS
References ActionListeners that will be set to the buttons.

CHECK_BOX_ITEM_LISTENERS

protected java.awt.event.ItemListener[] CHECK_BOX_ITEM_LISTENERS
References ItemListeners that will be set to the checkboxes.

checkBoxes

protected javax.swing.JCheckBox[] checkBoxes
References all the checkboxes.

enterMessageField

protected javax.swing.JTextField enterMessageField
Accepts a message that can be sent to the remote player.

enterMessageFieldLabel

protected javax.swing.JLabel enterMessageFieldLabel
The label for enterMessageField.

gameField

protected GameField gameField
The gamefield.

gameRunningButtons

protected javax.swing.JButton[] gameRunningButtons
References buttons that are enabled only when a game is running.

gameStateButtons

protected javax.swing.JButton[] gameStateButtons
References buttons that are grouped together.

isConnectedToAPlayer

protected boolean isConnectedToAPlayer
True if the player is connected to a remote player; false otherwise.

isGameRunning

protected boolean isGameRunning
True if a game is running; false otherwise.

isLocalPlayerMove

protected boolean isLocalPlayerMove
True if it's the local player's turn; false otherwise.

isRequestingForANewGame

protected boolean isRequestingForANewGame
True if the local player has sent a request for a new game to the remote player; false otherwise.

localPlayerCurrentTimeLabel

protected javax.swing.JLabel localPlayerCurrentTimeLabel
Shows the duration of the local player's current turn or of the previous turn if it is not the local player's turn.

localPlayerHighlightedImageIcon

protected javax.swing.ImageIcon localPlayerHighlightedImageIcon
The icon contains the highlighted version of the symbol the local player makes (a cross or a circle).

localPlayerIcon

protected javax.swing.JLabel localPlayerIcon
Holds the icon for the local player. The icon contains the symbol the local player makes (a cross or a circle) and is highlighted during the local player's turn.

localPlayerImageIcon

protected javax.swing.ImageIcon localPlayerImageIcon
The icon contains the symbol the local player makes (a cross or a circle).

localPlayerLabels

protected javax.swing.JLabel[] localPlayerLabels
References labels that hold information about the local player.

localPlayerNameLabel

protected javax.swing.JLabel localPlayerNameLabel
Shows the name of the local player.

localPlayerOverallTimeLabel

protected javax.swing.JLabel localPlayerOverallTimeLabel
Shows the duration of the local player's moves during the current game or the previous game if a new game has not been started yet.

localPlayerScore

protected int localPlayerScore
The score of the local player.

localPlayerScoreLabel

protected javax.swing.JLabel localPlayerScoreLabel
Shows the score of the local player.

messageArea

protected javax.swing.JTextArea messageArea
Holds the messages that have been sent between the players.

monitor

protected GameClient.GameScreen.Monitor monitor
Handles local player moves and updates the time counts.

ON_CLEAR_MESSAGE_AREA_BUTTON_CLICK

protected final java.awt.event.ActionListener ON_CLEAR_MESSAGE_AREA_BUTTON_CLICK
The event handler for the "Clear" button. Clears messageArea.

ON_NEW_GAME_BUTTON_CLICK

protected final java.awt.event.ActionListener ON_NEW_GAME_BUTTON_CLICK
The event handler for the "New game" button. Asks the player for confirmation and, if confirmed, sends a request for a new game to the remote player.

ON_QUIT_GAME_BUTTON_CLICK

protected final java.awt.event.ActionListener ON_QUIT_GAME_BUTTON_CLICK
The event handler for the "Quit game" button. Asks the user for confirmation and, if confirmed, calls terminate() from GameScreen.

ON_QUIT_TO_START_SCREEN_BUTTON_CLICK

protected final java.awt.event.ActionListener ON_QUIT_TO_START_SCREEN_BUTTON_CLICK
The event handler for the "Return to start screen" button. Asks the player for confirmation and, if confirmed, informs the server and brings up a StartScreen.

ON_SEND_MESSAGE_BUTTON_CLICK

protected final java.awt.event.ActionListener ON_SEND_MESSAGE_BUTTON_CLICK
The event handler for the "Send" button. Sends the entered message to the remote player and adds it to messageArea.

ON_SHOW_LOCAL_PLAYER_LAST_MOVE_CHECK_BOX_CLICK

protected final java.awt.event.ItemListener ON_SHOW_LOCAL_PLAYER_LAST_MOVE_CHECK_BOX_CLICK
The event handler for the "Show my last move" checkbox. Calls setLocalPlayerLastSquareHighlighted(boolean) from GameField.

ON_SHOW_REMOTE_PLAYER_LAST_MOVE_CHECK_BOX_CLICK

protected final java.awt.event.ItemListener ON_SHOW_REMOTE_PLAYER_LAST_MOVE_CHECK_BOX_CLICK
The event handler for the "Show remote player's last move" checkbox. Calls setRemotePlayerLastSquareHighlighted(boolean) from GameField.

ON_SURRENDER_GAME_BUTTON_CLICK

protected final java.awt.event.ActionListener ON_SURRENDER_GAME_BUTTON_CLICK
The event handler for the "Surrender" button. Asks the player for confirmation and, if confirmed, changes the interface accordingly and informs the remote player.

ON_WAIT_FOR_NEW_PLAYER_BUTTON_CLICK

protected final java.awt.event.ActionListener ON_WAIT_FOR_NEW_PLAYER_BUTTON_CLICK
The event handler for the "Wait for new player" button. Asks the player for confirmation and, if confirmed, drops the remote player, if any, and sets the interface accordingly to wait for a new player.

overallTimeLabel

protected javax.swing.JLabel overallTimeLabel
Shows the duration of the game in progress or of the previous game if a new one has not been started yet.

playerExistsButtons

protected javax.swing.JButton[] playerExistsButtons
References buttons that are enabled only when a remote player is present.

playerNameLabels

protected javax.swing.JLabel[] playerNameLabels
References labels that show the names of the players.

playerScoreLabels

protected javax.swing.JLabel[] playerScoreLabels
References labels that show the scores of the players.

playerTimeLabels

protected javax.swing.JLabel[] playerTimeLabels
References labels that show the times of the players.

remotePlayerCurrentTimeLabel

protected javax.swing.JLabel remotePlayerCurrentTimeLabel
Shows the duration of the remote player's current turn or of the previous turn if it is not the remote player's turn.

remotePlayerHighlightedImageIcon

protected javax.swing.ImageIcon remotePlayerHighlightedImageIcon
The icon contains the highlighted version of the symbol the remote player makes (a cross or a circle).

remotePlayerIcon

protected javax.swing.JLabel remotePlayerIcon
Holds the icon for the remote player. The icon contains the symbol the remote player makes (a cross or a circle) and is highlighted during the remote player's turn.

remotePlayerImageIcon

protected javax.swing.ImageIcon remotePlayerImageIcon
The icon contains the symbol the remote player makes (a cross or a circle).

remotePlayerLabels

protected javax.swing.JLabel[] remotePlayerLabels
References labels that hold information about the remote player.

remotePlayerName

protected java.lang.String remotePlayerName
The name of the remote player.

remotePlayerNameLabel

protected javax.swing.JLabel remotePlayerNameLabel
Shows the name of the remote player or "(NO PLAYER)" if no remote player has not joined yet or, if the remote player quit, the name of the remote player plus " (QUIT)".

remotePlayerOverallTimeLabel

protected javax.swing.JLabel remotePlayerOverallTimeLabel
Shows the duration of the remote player's moves during the current game or the previous game if a new game has not been started yet.

remotePlayerScore

protected int remotePlayerScore
The score of the remote player.

remotePlayerScoreLabel

protected javax.swing.JLabel remotePlayerScoreLabel
Shows the score of the remote player.

timeFormatter

protected java.text.SimpleDateFormat timeFormatter
Is used to convert a time in milliseconds into a HH:mm:ss format.
Constructor Detail

GameClient.GameScreen

public GameClient.GameScreen(boolean isLocalPlayerDrawingCircles,
                             boolean isConnectedToAPlayer,
                             java.lang.String remotePlayerName)
Constructs a GameScreen. The isConnectedToAPlayer argument determines whether the player can make a move (if there is a remote player present, i.e. the local player joined somebody).
Parameters:
isLocalPlayerDrawingCircles - true if the local player draws circles; false if the local player draws crosses
isConnectedToAPlayer - true if there is a remote player present; false otherwise
remotePlayerName - the name of the remote player joined, or null
Method Detail

addLocalPlayerMessageToMessageArea

public void addLocalPlayerMessageToMessageArea(java.lang.String toBeAdded)
Adds toBeAdded with the local player name and current time to messageArea. Uses addTextToMessageArea(String).
Parameters:
toBeAdded - the text to be added

addRemotePlayerMessageToMessageArea

public void addRemotePlayerMessageToMessageArea(java.lang.String toBeAdded)
Adds toBeAdded with the remote player name and current time to messageArea. Uses addTextToMessageArea(String).
Parameters:
toBeAdded - the text to be added

addTextToMessageArea

public void addTextToMessageArea(java.lang.String toBeAdded)
Adds toBeAdded to messageArea. The messageArea is emptied first if it has reached its capacity limit. The "Clear" button is enabled.
Parameters:
toBeAdded - the text to be added

changePlayerHighlight

public void changePlayerHighlight(boolean highlightLocalPlayer)
Changes the highlight of players - sets one highlighted and the other unhighlighted.
Parameters:
highlightLocalPlayer - true if the local player icon must highlighted; false if the remote player icon must be highlighted

handleMoveMadeMessage

public void handleMoveMadeMessage(int[] square)
Handles a message from the server indicating that the remote player made a move. Updates the interface accordingly.
Parameters:
square - the coordinates of the move made

handleNewGameAcceptedMessage

public void handleNewGameAcceptedMessage()
Handles a message from the server indicating that the remote player accepted a new game. Updates the interface accordingly and shows a message.

handleNewGameRefusedMessage

public void handleNewGameRefusedMessage()
Handles a message from the server indicating that the remote player refused a new game. Updates the interface accordingly and shows a message.

handleNewGameRequestedMessage

public void handleNewGameRequestedMessage()
Handles a message from the server indicating that the remote player requested for a new game. Asks the local player for confirmation and, if confirmed, starts a new game with the local player making the first move. Informs the remote player.

handlePlayerDroppedMessage

public void handlePlayerDroppedMessage()
Handles a message from the server indicating that the remote player dropped the local player. Updates the interface accordingly and shows a message.

handlePlayerJoinedMessage

public void handlePlayerJoinedMessage(java.lang.String playerName)
Handles a message from the server indicating that a remote player joined the game. Updates the interface accordingly and shows a message.
Parameters:
playerName - the name of the joining player

handlePlayerQuitMessage

public void handlePlayerQuitMessage()
Handles a message from the server indicating that the remote player quit. Updates the interface accordingly and shows a message.

handlePlayerReturnedToStartScreenMessage

public void handlePlayerReturnedToStartScreenMessage()
Handles a message from the server indicating that the remote player returned to start screen. Updates the interface accordingly and shows a message.

handlePlayerSurrenderedMessage

public void handlePlayerSurrenderedMessage()
Handles a message from the server indicating that the remote player surrenderer. Updates the interface accordingly and shows a message.

handleTextMessage

public void handleTextMessage(java.lang.String message)
Handles a message from the server indicating that the remote player sent a message. Adds the text to messageArea.
Parameters:
message - the text sent

handleWinningMoveMadeMessage

public void handleWinningMoveMadeMessage(int[][] squares)
Handles a message from the server indicating that the remote player made a winning move. Updates the interface accordingly and shows a message.
Parameters:
squares - the coordinates of the winning squares

increaseLocalPlayerScore

public void increaseLocalPlayerScore()
Increases the local player's score and updates the interface.

increaseRemotePlayerScore

public void increaseRemotePlayerScore()
Increases the remote player's score and updates the interface.

setInterfaceToGameOverMode

public void setInterfaceToGameOverMode(boolean isGameOver)
Sets the interface to game over mode or game running mode.
Parameters:
isGameOver - true if the game is over; false otherwise

setInterfaceToLocalPlayerMoveMode

public void setInterfaceToLocalPlayerMoveMode(boolean interfaceToLocalPlayerMoveMode)
Changes the interface to reflect whose move it is.
Parameters:
interfaceToLocalPlayerMoveMode - true if the interface will be set to reflect that it is the local player's move; false if the interface will be set to reflect that it is the remote player' move

setNeededComponentsEnabled

public void setNeededComponentsEnabled(boolean enabled)
Sets certain predetermined components enabled or disabled. Used when performing functions like requesting for a new game etc.
Parameters:
enabled - true if the components must be enabled; false otherwise

setPlayerIconsUnhighlighted

public void setPlayerIconsUnhighlighted()
Unhighlights the player icons.