|
||||||||
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 | +--javax.swing.JComponent | +--javax.swing.JPanel | +--thegame.client.GameClient.GameScreen
The game screen.
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 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 |
protected javax.swing.JButton[] allButtons
protected java.awt.event.ActionListener[] BUTTON_ACTION_LISTENERS
protected java.awt.event.ItemListener[] CHECK_BOX_ITEM_LISTENERS
protected javax.swing.JCheckBox[] checkBoxes
protected javax.swing.JTextField enterMessageField
protected javax.swing.JLabel enterMessageFieldLabel
protected GameField gameField
protected javax.swing.JButton[] gameRunningButtons
protected javax.swing.JButton[] gameStateButtons
protected boolean isConnectedToAPlayer
protected boolean isGameRunning
protected boolean isLocalPlayerMove
protected boolean isRequestingForANewGame
protected javax.swing.JLabel localPlayerCurrentTimeLabel
protected javax.swing.ImageIcon localPlayerHighlightedImageIcon
protected javax.swing.JLabel localPlayerIcon
protected javax.swing.ImageIcon localPlayerImageIcon
protected javax.swing.JLabel[] localPlayerLabels
protected javax.swing.JLabel localPlayerNameLabel
protected javax.swing.JLabel localPlayerOverallTimeLabel
protected int localPlayerScore
protected javax.swing.JLabel localPlayerScoreLabel
protected javax.swing.JTextArea messageArea
protected GameClient.GameScreen.Monitor monitor
protected final java.awt.event.ActionListener ON_CLEAR_MESSAGE_AREA_BUTTON_CLICK
protected final java.awt.event.ActionListener ON_NEW_GAME_BUTTON_CLICK
protected final java.awt.event.ActionListener ON_QUIT_GAME_BUTTON_CLICK
protected final java.awt.event.ActionListener ON_QUIT_TO_START_SCREEN_BUTTON_CLICK
protected final java.awt.event.ActionListener ON_SEND_MESSAGE_BUTTON_CLICK
protected final java.awt.event.ItemListener ON_SHOW_LOCAL_PLAYER_LAST_MOVE_CHECK_BOX_CLICK
protected final java.awt.event.ItemListener ON_SHOW_REMOTE_PLAYER_LAST_MOVE_CHECK_BOX_CLICK
protected final java.awt.event.ActionListener ON_SURRENDER_GAME_BUTTON_CLICK
protected final java.awt.event.ActionListener ON_WAIT_FOR_NEW_PLAYER_BUTTON_CLICK
protected javax.swing.JLabel overallTimeLabel
protected javax.swing.JButton[] playerExistsButtons
protected javax.swing.JLabel[] playerNameLabels
protected javax.swing.JLabel[] playerScoreLabels
protected javax.swing.JLabel[] playerTimeLabels
protected javax.swing.JLabel remotePlayerCurrentTimeLabel
protected javax.swing.ImageIcon remotePlayerHighlightedImageIcon
protected javax.swing.JLabel remotePlayerIcon
protected javax.swing.ImageIcon remotePlayerImageIcon
protected javax.swing.JLabel[] remotePlayerLabels
protected java.lang.String remotePlayerName
protected javax.swing.JLabel remotePlayerNameLabel
protected javax.swing.JLabel remotePlayerOverallTimeLabel
protected int remotePlayerScore
protected javax.swing.JLabel remotePlayerScoreLabel
protected java.text.SimpleDateFormat timeFormatter
Constructor Detail |
public GameClient.GameScreen(boolean isLocalPlayerDrawingCircles, boolean isConnectedToAPlayer, java.lang.String remotePlayerName)
isLocalPlayerDrawingCircles
- true if the local player draws circles; false if the local player draws crossesisConnectedToAPlayer
- true if there is a remote player present; false otherwiseremotePlayerName
- the name of the remote player joined, or nullMethod Detail |
public void addLocalPlayerMessageToMessageArea(java.lang.String toBeAdded)
toBeAdded
- the text to be addedpublic void addRemotePlayerMessageToMessageArea(java.lang.String toBeAdded)
toBeAdded
- the text to be addedpublic void addTextToMessageArea(java.lang.String toBeAdded)
toBeAdded
- the text to be addedpublic void changePlayerHighlight(boolean highlightLocalPlayer)
highlightLocalPlayer
- true if the local player icon must highlighted; false if the remote player icon must be highlightedpublic void handleMoveMadeMessage(int[] square)
square
- the coordinates of the move madepublic void handleNewGameAcceptedMessage()
public void handleNewGameRefusedMessage()
public void handleNewGameRequestedMessage()
public void handlePlayerDroppedMessage()
public void handlePlayerJoinedMessage(java.lang.String playerName)
playerName
- the name of the joining playerpublic void handlePlayerQuitMessage()
public void handlePlayerReturnedToStartScreenMessage()
public void handlePlayerSurrenderedMessage()
public void handleTextMessage(java.lang.String message)
message
- the text sentpublic void handleWinningMoveMadeMessage(int[][] squares)
squares
- the coordinates of the winning squarespublic void increaseLocalPlayerScore()
public void increaseRemotePlayerScore()
public void setInterfaceToGameOverMode(boolean isGameOver)
isGameOver
- true if the game is over; false otherwisepublic void setInterfaceToLocalPlayerMoveMode(boolean interfaceToLocalPlayerMoveMode)
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' movepublic void setNeededComponentsEnabled(boolean enabled)
enabled
- true if the components must be enabled; false otherwisepublic void setPlayerIconsUnhighlighted()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |