|
||||||||
| 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
|
+--au.com.solidsoftware.multimahjong.mmc.usergui.ActionPane
The pane containing the action buttons allowing the user to interact with the underlying MultiMahjong game engine. There seven action buttons in this pane. In order from top to bottom, these buttons allow the user to "Declare Kong", "Pickup", "Discard", "Chow", "Pung", "Kong" and "Mahjong":

Each button may be either disabled or enabled. The state of the button is
determined by the Game object and is dependent upon the legal
moves that user may carry out. The diagram below shows the disabled and
enabled state of the action buttons:

When enabled, the appearance of the button will change when the user moves the cursor over it. The appearance of the button will also change when the user clicks on it. The diagram below shows the rollover and pressed state of the action buttons:

To prevent users from spending too long deciding on whether to execute a game action, a timer is built into the action pane. This timer will become activated when the user is given the option to Pung, Kong, or Mahjong. After a delay of 10 seconds, the option will expire, and a Pass action is sent automatically. A countdown is shown unobstructive in the bottom-right hand corner of the action pane to inform the user of the time remaining. In the diagram below, the user has five seconds remaining before making a decision to Pung:

| Inner Class Summary | |
private class |
ActionPane.RolloverButton
A specialised rollover-enabled button which corrects some quirks/annoyances within JButton, making it more suited for
use with graphical buttons. |
| Inner classes inherited from class javax.swing.JPanel |
javax.swing.JPanel.AccessibleJPanel |
| Inner classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent,
javax.swing.JComponent.IntVector,
javax.swing.JComponent.KeyboardBinding,
javax.swing.JComponent.KeyboardState |
| Inner classes inherited from class java.awt.Component |
java.awt.Component.AWTTreeLock |
| Field Summary | |
private javax.swing.Timer |
autopass
The timer that fires off an action events every second. |
static int |
CHOW
Symbolic constant used to refer to the "Chow" button. |
private ActionPane.RolloverButton |
chowButton
The "Chow" button. |
private int |
countdown
The time in seconds remaining before we automatically pass for the player. |
private javax.swing.JLabel |
countdownLabel
The label showing the seconds remaining before we automatically pass for the player. |
static int |
DECLARE
Symbolic constant used to refer to the "Declare Kong" button. |
private ActionPane.RolloverButton |
declareButton
The "Declare Kong" button. |
static int |
DISCARD
Symbolic constant used to refer to the "Discard" button. |
private ActionPane.RolloverButton |
discardButton
The "Discard" button. |
static int |
KONG
Symbolic constant used to refer to the "Kong" button. |
private ActionPane.RolloverButton |
kongButton
The "Kong" button. |
static int |
MAHJONG
Symbolic constant used to refer to the "Mahjong" button. |
private ActionPane.RolloverButton |
mahjongButton
The "Mahjong" button. |
static int |
PICKUP
Symbolic constant used to refer to the "Pickup" button. |
private ActionPane.RolloverButton |
pickupButton
The "Pickup" button. |
static int |
PUNG
Symbolic constant used to refer to the "Pung" button. |
private ActionPane.RolloverButton |
pungButton
The "Pung" button. |
private Tile |
selected
The tile that has been selected by the user in the UserPane. |
private UserGUI |
userGUI
A reference to the parent UserGUI object. |
| Fields inherited from class javax.swing.JPanel |
defaultLayout,
uiClassID |
| Fields inherited from class javax.swing.JComponent |
_bounds,
accessibleContext,
alignmentX,
alignmentY,
ANCESTOR_USING_BUFFER,
ancestorNotifier,
autoscroller,
border,
changeSupport,
clientProperties,
flags,
HAS_FOCUS,
IS_DOUBLE_BUFFERED,
IS_OPAQUE,
IS_PAINTING_TILE,
KEYBOARD_BINDINGS_KEY,
listenerList,
maximumSize,
minimumSize,
NEXT_FOCUS,
paintImmediatelyClip,
preferredSize,
readObjectCallbacks,
REQUEST_FOCUS_DISABLED,
tmpRect,
TOOL_TIP_TEXT_KEY,
ui,
uiClassID,
UNDEFINED_CONDITION,
vetoableChangeSupport,
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
WHEN_FOCUSED,
WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Container |
component,
containerListener,
containerSerializedDataVersion,
dispatcher,
layoutMgr,
maxSize,
ncomponents,
serialVersionUID |
| Fields inherited from class java.awt.Component |
actionListenerK,
adjustmentListenerK,
appContext,
assert,
background,
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
changeSupport,
componentListener,
componentListenerK,
componentOrientation,
componentSerializedDataVersion,
containerListenerK,
cursor,
dropTarget,
enabled,
eventMask,
focusListener,
focusListenerK,
font,
foreground,
hasFocus,
height,
incRate,
inputMethodListener,
inputMethodListenerK,
isInc,
isPacked,
itemListenerK,
keyListener,
keyListenerK,
LEFT_ALIGNMENT,
locale,
LOCK,
minSize,
mouseListener,
mouseListenerK,
mouseMotionListener,
mouseMotionListenerK,
name,
nameExplicitlySet,
newEventsOnly,
ownedWindowK,
parent,
peer,
peerFont,
popups,
prefSize,
RIGHT_ALIGNMENT,
serialVersionUID,
textListenerK,
TOP_ALIGNMENT,
valid,
visible,
width,
windowListenerK,
x,
y |
| Constructor Summary | |
ActionPane(UserGUI userGUI)
Creates an instance of ActionPane with all the buttons
initially in a disabled, greyed-out state. |
|
| Method Summary | |
void |
disableAll()
Disables all the action buttons in this pane. |
void |
enableButton(int button)
Enables a specific action button in this pane. |
static void |
main(java.lang.String[] args)
Driver code used for unit testing. |
void |
setSelected(Tile tile)
Stores the tile that has been selected by the user in the PlayArea. |
private void |
showChowSelectionDialog(UserGUI userGUI)
Displays a dialog box allowing the user to select between the possible ways of forming an exposed chow with the last discard. |
void |
showRobKongDialogBox(UserGUI userGUI)
Shows a confirm dialog box allowing the user to choose whether to rob a kong when the opportunity arises. |
| Methods inherited from class javax.swing.JPanel |
|
| Methods inherited from class javax.swing.JComponent |
_paintImmediately,
addAncestorListener,
addNotify,
addPropertyChangeListener,
addVetoableChangeListener,
adjustPaintFlags,
alwaysOnTop,
bindingForKeyStroke,
computeVisibleRect,
computeVisibleRect,
contains,
createToolTip,
enableSerialization,
firePropertyChange,
firePropertyChange,
firePropertyChange,
firePropertyChange,
firePropertyChange,
firePropertyChange,
firePropertyChange,
firePropertyChange,
firePropertyChange,
fireVetoableChange,
getActionForKeyStroke,
getAlignmentX,
getAlignmentY,
getAutoscrolls,
getBorder,
getBounds,
getClientProperties,
getClientProperty,
getComponentGraphics,
getConditionForKeyStroke,
getDebugGraphicsOptions,
getFlag,
getGraphics,
getHeight,
getInsets,
getInsets,
getLocation,
getMaximumSize,
getMinimumSize,
getNextFocusableComponent,
getPreferredSize,
getRegisteredKeyStrokes,
getRootPane,
getSize,
getToolTipLocation,
getToolTipText,
getToolTipText,
getTopLevelAncestor,
getVisibleRect,
getWidth,
getX,
getY,
grabFocus,
hasFocus,
isDoubleBuffered,
isFocusCycleRoot,
isFocusTraversable,
isLightweightComponent,
isManagingFocus,
isOpaque,
isOptimizedDrawingEnabled,
isPaintingTile,
isRequestFocusEnabled,
isValidateRoot,
keyboardBindings,
paint,
paintBorder,
paintChildren,
paintComponent,
paintImmediately,
paintImmediately,
paintWithBuffer,
processComponentKeyEvent,
processFocusEvent,
processKeyBinding,
processKeyBindings,
processKeyBindingsForAllComponents,
processKeyEvent,
processMouseMotionEvent,
putClientProperty,
readObject,
rectangleIsObscured,
registerKeyboardAction,
registerKeyboardAction,
registerWithKeyboardManager,
removeAncestorListener,
removeNotify,
removePropertyChangeListener,
removeVetoableChangeListener,
repaint,
repaint,
requestDefaultFocus,
requestFocus,
resetKeyboardActions,
reshape,
revalidate,
scrollRectToVisible,
setAlignmentX,
setAlignmentY,
setAutoscrolls,
setBackground,
setBorder,
setDebugGraphicsOptions,
setDoubleBuffered,
setEnabled,
setFlag,
setFont,
setForeground,
setMaximumSize,
setMinimumSize,
setNextFocusableComponent,
setOpaque,
setPreferredSize,
setRequestFocusEnabled,
setToolTipText,
setUI,
setVisible,
shouldDebugGraphics,
superProcessMouseMotionEvent,
unregisterKeyboardAction,
unregisterWithKeyboardManager,
update |
| Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
applyOrientation,
countComponents,
deliverEvent,
dispatchEventImpl,
dispatchEventToSelf,
doLayout,
eventEnabled,
findComponentAt,
findComponentAt,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents_NoClientCode,
getComponents,
getLayout,
getMouseEventTarget,
getWindow,
initIDs,
insets,
invalidate,
invalidateTree,
isAncestorOf,
layout,
lightweightPrint,
list,
list,
locate,
minimumSize,
nextFocus,
paintComponents,
postProcessKeyEvent,
postsOldMouseEvents,
preferredSize,
preProcessKeyEvent,
print,
printComponents,
printOneComponent,
processContainerEvent,
processEvent,
proxyEnableEvents,
proxyRequestFocus,
remove,
remove,
removeAll,
removeContainerListener,
setFocusOwner,
setLayout,
transferFocus,
validate,
validateTree |
| Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addPropertyChangeListener,
areInputMethodsEnabled,
bounds,
checkImage,
checkImage,
coalesceEvents,
constructComponentName,
contains,
createImage,
createImage,
disable,
disableEvents,
dispatchEvent,
enable,
enable,
enableEvents,
enableInputMethods,
getBackground,
getBounds,
getColorModel,
getComponentOrientation,
getCursor,
getDropTarget,
getFont_NoClientCode,
getFont,
getFontMetrics,
getForeground,
getInputContext,
getInputMethodRequests,
getLocale,
getLocation,
getLocationOnScreen,
getName,
getNativeContainer,
getParent_NoClientCode,
getParent,
getPeer,
getSize,
getToolkit,
getToolkitImpl,
getTreeLock,
getWindowForObject,
gotFocus,
handleEvent,
hide,
imageUpdate,
inside,
isDisplayable,
isEnabled,
isEnabledImpl,
isLightweight,
isShowing,
isValid,
isVisible,
keyDown,
keyUp,
list,
list,
list,
location,
lostFocus,
mouseDown,
mouseDrag,
mouseEnter,
mouseExit,
mouseMove,
mouseUp,
move,
nextFocus,
paintAll,
postEvent,
prepareImage,
prepareImage,
printAll,
processComponentEvent,
processInputMethodEvent,
processMouseEvent,
remove,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removePropertyChangeListener,
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,
registerNatives,
wait,
wait,
wait |
| Field Detail |
public static final int DECLARE
enableButton method.public static final int PICKUP
enableButton method.public static final int DISCARD
enableButton method.public static final int CHOW
enableButton method.public static final int PUNG
enableButton method.public static final int KONG
enableButton method.public static final int MAHJONG
enableButton method.private ActionPane.RolloverButton declareButton
ActionListener attached to
this button invokes the Human.setMove(selected,
Player.DECLARE) method upon receiving an
ActionEvent.Human.setMove(au.com.solidsoftware.multimahjong.shared.Tile, int)private ActionPane.RolloverButton pickupButton
ActionListener attached to this
button invokes Human.setSelection(Player.PICKUP) upon
receiving an ActionEvent.Human.setSelection(int)private ActionPane.RolloverButton discardButton
ActionListener attached to this
button invokes Human.setMove(selected, Player.DISCARD) upon
receiving an ActionEvent.Human.setMove(au.com.solidsoftware.multimahjong.shared.Tile, int)private ActionPane.RolloverButton chowButton
ActionListener attached to this
button invokes the showChowSelectionDialog() method upon
receiving an ActionEvent.Human.setSelection(int)private ActionPane.RolloverButton pungButton
ActionListener attached to this
button invokes Human.setSelection(Player.PUNG) upon
receiving an ActionEvent.Human.setSelection(int)private ActionPane.RolloverButton kongButton
ActionListener attached to this
button invokes Human.setSelection(Player.KONG) upon
receiving an ActionEvent.Human.setSelection(int)private ActionPane.RolloverButton mahjongButton
ActionListener attached to this
button invokes Human.setSelection(Player.MAHJONG) upon
receiving an ActionEvent.Human.setSelection(int)private UserGUI userGUI
UserGUI object.private Tile selected
UserPane. This field can be updated via the
setSelected method.private javax.swing.Timer autopass
Human.setSelection(Player.NO_MOVE) method
is invoked. In effect, this gives the user exactly ten seconds to decide
whether to execute a game action - when these ten seconds lapse, an
automatic "Pass" is assumed.Human.setSelection(int)private int countdown
private javax.swing.JLabel countdownLabel
| Constructor Detail |
public ActionPane(UserGUI userGUI)
ActionPane with all the buttons
initially in a disabled, greyed-out state. Seven action buttons are
added to this pane. In order from top to bottom, these buttons allow the
user to "Declare Kong", "Pickup", "Discard", "Chow", "Pung", "Kong" and
"Mahjong". An ActionListener is added to each of these
buttons to invoke the Human.setSelection(int) or Human.setMove(au.com.solidsoftware.multimahjong.shared.Tile, int)
method upon receiving an ActionEvent, which in turn
registers the action with the Game object.userGUI - a reference to the parent UserGUI object| Method Detail |
public void disableAll()
public void enableButton(int button)
ActionEvent, which is then passed to every
ActionListener that have registered to receive this via
the button's addActionListener method.button - A symbolic constant referring to the action button to be
enabled. If an unrecognisable symbolic contant is
encountered, no action will be carried out.public void setSelected(Tile tile)
PlayArea. The selected tile must be stored locally because
some ActionListeners invoke the Human.setMove(au.com.solidsoftware.multimahjong.shared.Tile, int)
method, which takes the selected tile as an argument.tile - The tile that has been selected by the user in the
PlayArea. This may be null,
signifying that there are no tiles selected in the
UserPane.private void showChowSelectionDialog(UserGUI userGUI)
userGUI - A reference to the parent UserGUI object.public void showRobKongDialogBox(UserGUI userGUI)
Human.userGUI - a reference to the parent UserGUI objectpublic static void main(java.lang.String[] args)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||