Class Board

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by Board
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.ComponentListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class Board
extends javax.swing.JPanel
implements java.awt.event.ComponentListener, java.awt.event.ActionListener

This class creates a Frame by extending JPanel. A Checker Board is created in the panel. public

See Also:
Serialized Form

Nested Class Summary
 class Board.DemoAdapter
          This nested class is to allow the use of the MouseAdapter class Extends MouseAdapter public
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  Board boardRef
           
protected  int btmplayer
           
protected  Piece[][] ch
           
protected  int currentPlayer
           
protected  Piece draggedPiece
           
protected  javax.swing.JFrame frame
           
protected static boolean gameOver
           
protected  java.awt.Image image
           
protected static boolean notReady
           
protected  java.awt.Graphics offscreen
           
protected  boolean playerIsMidJump
           
protected  Player[] players
           
protected  Square[][] sq
           
protected  javax.swing.JLabel status1
           
protected  javax.swing.JLabel status2
           
protected  javax.swing.JLabel status3
           
protected  int thisPlayer
           
protected  int topplayer
           
protected  int width
          Any constant values multiplied by width divided by 90 represents a proportionality constant.
 
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
Board()
          This is the constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          This method overrides an interface method
 void componentHidden(java.awt.event.ComponentEvent e)
          This method overrides an interface method
 void componentMoved(java.awt.event.ComponentEvent e)
          This method overrides an interface method
 void componentResized(java.awt.event.ComponentEvent e)
          This method is called in the event that the board is resized
 void componentShown(java.awt.event.ComponentEvent e)
          This method overrides an interface method
 void crownCheck(int col, int row)
          This method checks if a piece should be crowned.
 void crownedKing(int col, int row)
          This method creates a new king and crowns it.
 void endGame()
          This metond sets the gameOver public
 void handleMove(int col, int row)
          This method is used to handle the move of a piece
 void initPlayer(java.lang.String[] args)
          This method initializes the players and netplayers in accordance with the command line argurments
static void main(java.lang.String[] args)
          This method is the driver of the Board.
 void paint(java.awt.Graphics g)
          This method overrides the JPanel paint method.
 void resetPiece()
          This method returns the piece back to its original postion
 void setLabel()
          This method sets the label for the status bar.
 void setUpBoard(java.lang.String[] args)
          This method sets up the board (8 X 8) with all the squares.
 void setupLabel(javax.swing.JFrame f)
          Creates a JLabel to display information about Player and turns.
 void setupMenu(javax.swing.JFrame f)
          This method sets us the menu bar with File and Option File allows for exiting of the game.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sq

protected Square[][] sq

ch

protected Piece[][] ch

boardRef

protected Board boardRef

draggedPiece

protected Piece draggedPiece

players

protected Player[] players

thisPlayer

protected int thisPlayer

currentPlayer

protected int currentPlayer

playerIsMidJump

protected boolean playerIsMidJump

notReady

protected static boolean notReady

gameOver

protected static boolean gameOver

status1

protected javax.swing.JLabel status1

status2

protected javax.swing.JLabel status2

status3

protected javax.swing.JLabel status3

frame

protected javax.swing.JFrame frame

topplayer

protected int topplayer

btmplayer

protected int btmplayer

image

protected java.awt.Image image

offscreen

protected java.awt.Graphics offscreen

width

protected int width
Any constant values multiplied by width divided by 90 represents a proportionality constant. Since there are many constants that represent vastly different proportions, it is impractical to make them into constant variables.

Constructor Detail

Board

public Board()
This is the constructor.

Method Detail

setUpBoard

public void setUpBoard(java.lang.String[] args)
This method sets up the board (8 X 8) with all the squares. It sets the color of each square, determines if the square is able to receive a Piece, sets up an array of 12 pawns per Player and informs the square of its Pawn public

Parameters:
args - Command Arguments

initPlayer

public void initPlayer(java.lang.String[] args)
This method initializes the players and netplayers in accordance with the command line argurments

Parameters:
args - Command line arguments

paint

public void paint(java.awt.Graphics g)
This method overrides the JPanel paint method. Calls each square's drawSquare method Calls drawChecker on the draggedPiece if there is one. Implements Double Buffering public

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - uses Graphics passed in

setupMenu

public void setupMenu(javax.swing.JFrame f)
This method sets us the menu bar with File and Option File allows for exiting of the game. Option allows a choice of normal theme or Clemson theme

Parameters:
f - JFrame

setupLabel

public void setupLabel(javax.swing.JFrame f)
Creates a JLabel to display information about Player and turns.

Parameters:
f -

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
This method overrides an interface method

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e -

handleMove

public void handleMove(int col,
                       int row)
This method is used to handle the move of a piece

Parameters:
col - Column of move
row - Row of move

resetPiece

public void resetPiece()
This method returns the piece back to its original postion


crownCheck

public void crownCheck(int col,
                       int row)
This method checks if a piece should be crowned.

Parameters:
col - Column
row - Row

crownedKing

public void crownedKing(int col,
                        int row)
This method creates a new king and crowns it.

Parameters:
col - Column
row - Row

setLabel

public void setLabel()
This method sets the label for the status bar.


componentResized

public void componentResized(java.awt.event.ComponentEvent e)
This method is called in the event that the board is resized

Specified by:
componentResized in interface java.awt.event.ComponentListener
Parameters:
e - ComponentEvent

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
This method overrides an interface method

Specified by:
componentHidden in interface java.awt.event.ComponentListener
Parameters:
e - ComponentEvent

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
This method overrides an interface method

Specified by:
componentMoved in interface java.awt.event.ComponentListener
Parameters:
e - ComponentEvent

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
This method overrides an interface method

Specified by:
componentShown in interface java.awt.event.ComponentListener
Parameters:
e - ComponentEvent

endGame

public void endGame()
This metond sets the gameOver public


main

public static void main(java.lang.String[] args)
This method is the driver of the Board. It creates a new Board and calls the method setUpBoard. public static

Parameters:
args - command argruments