thegame.client
Class GameSquare

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.AbstractButton
                          |
                          +--javax.swing.JButton
                                |
                                +--thegame.client.GameSquare
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, javax.swing.SwingConstants

public class GameSquare
extends javax.swing.JButton

The game square. Can be clicked, circled, crossed, enabled and disabled.

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

Inner classes inherited from class javax.swing.JButton
javax.swing.JButton.AccessibleJButton
 
Inner classes inherited from class javax.swing.AbstractButton
javax.swing.AbstractButton.AccessibleAbstractButton, javax.swing.AbstractButton.ButtonChangeListener
 
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
static javax.swing.ImageIcon CIRCLED_ICON
           
static java.lang.String CIRCLED_ICON_PATH
           
static javax.swing.ImageIcon CLOSED_ICON
           
static java.lang.String CLOSED_ICON_PATH
           
static javax.swing.ImageIcon CROSSED_ICON
           
static java.lang.String CROSSED_ICON_PATH
           
static javax.swing.ImageIcon DEFAULT_ICON
           
static java.lang.String DEFAULT_ICON_PATH
           
static javax.swing.ImageIcon HIGHLIGHTED_CIRCLED_ICON
           
static java.lang.String HIGHLIGHTED_CIRCLED_ICON_PATH
           
static javax.swing.ImageIcon HIGHLIGHTED_CIRCLED_WINNING_ICON
           
static java.lang.String HIGHLIGHTED_CIRCLED_WINNING_ICON_PATH
           
static javax.swing.ImageIcon HIGHLIGHTED_CROSSED_ICON
           
static java.lang.String HIGHLIGHTED_CROSSED_ICON_PATH
           
static javax.swing.ImageIcon HIGHLIGHTED_CROSSED_WINNING_ICON
           
static java.lang.String HIGHLIGHTED_CROSSED_WINNING_ICON_PATH
           
protected  boolean isCircled
          Is true if the square is circled, is false otherwise.
protected  boolean isCrossed
          Is true if the square is crossed, is false otherwise.
protected  boolean isWinningSquare
          Is true if the square has been circled or crossed and is part of a winning row.
protected  int[] position
          The position of the square on the gamefield.
static javax.swing.ImageIcon PRESSED_ICON
           
static java.lang.String PRESSED_ICON_PATH
           
 
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NORTH, NORTH_EAST, NORTH_WEST, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GameSquare(int[] position)
          Constructs a GameSquare.
 
Method Summary
 int[] getPosition()
          Returns the position property
 boolean isCircled()
          Returns the isCircled property.
 boolean isCrossed()
          Returns the isCrossed property.
 boolean isEmpty()
          Returns true if the square is empty (neither crossed nor circled); false otherwise.
 boolean isFocusTraversable()
          Returns false to disable the square to receive keyboard focus.
 void reset(boolean enabled)
          Resets the square - sets it to be empty.
 void setCircled()
          Sets the square circled and disabled.
 void setClosed()
          Toggles the permanently disabled state of the square.
 void setCrossed()
          Sets the square crossed and disabled.
 void setEnabled(boolean enabled)
          Enables or disables user input.
 void setHighlighted(boolean highlighted)
          Toggles the highlighted state of the square.
 void setWinningSquare()
          Sets the square part of a winning row.
 
Methods inherited from class javax.swing.JButton
configurePropertiesFromAction, getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable, updateUI
 
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getDisabledIcon, getDisabledSelectedIcon, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getLabel, getMargin, getMnemonic, getModel, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setLabel, setMargin, setMnemonic, setMnemonic, setModel, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
 
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, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, 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, 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

CIRCLED_ICON

public static final javax.swing.ImageIcon CIRCLED_ICON

CIRCLED_ICON_PATH

public static final java.lang.String CIRCLED_ICON_PATH

CLOSED_ICON

public static final javax.swing.ImageIcon CLOSED_ICON

CLOSED_ICON_PATH

public static final java.lang.String CLOSED_ICON_PATH

CROSSED_ICON

public static final javax.swing.ImageIcon CROSSED_ICON

CROSSED_ICON_PATH

public static final java.lang.String CROSSED_ICON_PATH

DEFAULT_ICON

public static final javax.swing.ImageIcon DEFAULT_ICON

DEFAULT_ICON_PATH

public static final java.lang.String DEFAULT_ICON_PATH

HIGHLIGHTED_CIRCLED_ICON

public static final javax.swing.ImageIcon HIGHLIGHTED_CIRCLED_ICON

HIGHLIGHTED_CIRCLED_ICON_PATH

public static final java.lang.String HIGHLIGHTED_CIRCLED_ICON_PATH

HIGHLIGHTED_CIRCLED_WINNING_ICON

public static final javax.swing.ImageIcon HIGHLIGHTED_CIRCLED_WINNING_ICON

HIGHLIGHTED_CIRCLED_WINNING_ICON_PATH

public static final java.lang.String HIGHLIGHTED_CIRCLED_WINNING_ICON_PATH

HIGHLIGHTED_CROSSED_ICON

public static final javax.swing.ImageIcon HIGHLIGHTED_CROSSED_ICON

HIGHLIGHTED_CROSSED_ICON_PATH

public static final java.lang.String HIGHLIGHTED_CROSSED_ICON_PATH

HIGHLIGHTED_CROSSED_WINNING_ICON

public static final javax.swing.ImageIcon HIGHLIGHTED_CROSSED_WINNING_ICON

HIGHLIGHTED_CROSSED_WINNING_ICON_PATH

public static final java.lang.String HIGHLIGHTED_CROSSED_WINNING_ICON_PATH

isCircled

protected boolean isCircled
Is true if the square is circled, is false otherwise.

isCrossed

protected boolean isCrossed
Is true if the square is crossed, is false otherwise.

isWinningSquare

protected boolean isWinningSquare
Is true if the square has been circled or crossed and is part of a winning row. Is used in setHighlighted(boolean) - a winning square is not unhighlighted.

position

protected int[] position
The position of the square on the gamefield.

PRESSED_ICON

public static final javax.swing.ImageIcon PRESSED_ICON

PRESSED_ICON_PATH

public static final java.lang.String PRESSED_ICON_PATH
Constructor Detail

GameSquare

public GameSquare(int[] position)
Constructs a GameSquare.
Parameters:
position - the position of the square on the gamefield
Method Detail

getPosition

public int[] getPosition()
Returns the position property
Returns:
the position property

isCircled

public boolean isCircled()
Returns the isCircled property.
Returns:
the isCircled property

isCrossed

public boolean isCrossed()
Returns the isCrossed property.
Returns:
the isCrossed property

isEmpty

public boolean isEmpty()
Returns true if the square is empty (neither crossed nor circled); false otherwise.
Returns:
true if the square is empty; false otherwise

isFocusTraversable

public boolean isFocusTraversable()
Returns false to disable the square to receive keyboard focus.
Overrides:
isFocusTraversable in class javax.swing.AbstractButton
Returns:
false

reset

public void reset(boolean enabled)
Resets the square - sets it to be empty.

setCircled

public void setCircled()
Sets the square circled and disabled.

setClosed

public void setClosed()
Toggles the permanently disabled state of the square.

setCrossed

public void setCrossed()
Sets the square crossed and disabled.

setEnabled

public void setEnabled(boolean enabled)
Enables or disables user input. Does not disable the square, but modifies its behaviour to mimic a disabled square.
Overrides:
setEnabled in class javax.swing.AbstractButton
Parameters:
enabled - true if the square can receive user input; false otherwise

setHighlighted

public void setHighlighted(boolean highlighted)
Toggles the highlighted state of the square.
Parameters:
highlighted - if true, then the square will be highlighted; otherwise the square will be unhighlighted

setWinningSquare

public void setWinningSquare()
Sets the square part of a winning row. Highlights the square with a winning square icon.