|
||||||||
| 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.JTabbedPane
|
+--au.com.solidsoftware.multimahjong.mmc.usergui.TabbedPane
A tabbed pane that contains three tabs - a "Scores" tab, a "Discards" tab, and an "Options" tab. The "Scores" tab contains four rows, one for each player. Each row shows, from left to right, the player's icon, name and score.

The "Discards" tab contains a scrollpane which manages a scrollable client. The scrollable client displays dead tiles in the order in which they were discarded. Dead tiles are displayed from left to right, from bottom to top. By adding new dead tiles to the top of the scrollable client, we eliminate the need for the user to continuously scroll down to see new dead tiles.

The "Options" tab contains a check box allowing the user to toggle sound effects on and off. It also contains a "Leave Game" button, which will display a leave game dialog if pressed.

| Inner Class Summary | |
private class |
TabbedPane.DiscardsPane
An custom inner class used that overrides the paint method
in JLayeredPane, permitting each of the
discardTileImages to be drawn properly in a layered pane. |
private class |
TabbedPane.DiscardTileImage
An inner class used primarily for storing the x- and y-coordinate of a discarded tile, relative to the top-left corner of the discardsPane. |
| Inner classes inherited from class javax.swing.JTabbedPane |
javax.swing.JTabbedPane.AccessibleJTabbedPane,
javax.swing.JTabbedPane.ModelListener |
| 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 TabbedPane.DiscardsPane |
discardsPane
A reference to the scrollable client within the "Discards" tab. |
private TabbedPane.DiscardTileImage[] |
discardTileImages
This stores the images of all the tiles in the discardsPane. |
private javax.swing.JLabel[] |
playerLabel
An array of labels showing the icon and name for each of the players. |
private javax.swing.JLabel[] |
scoreLabel
An array of text-only labels showing the scores for each of the players. |
private UserGUI |
userGUI
A reference to the parent UserGUI object. |
| Fields inherited from class javax.swing.JTabbedPane |
changeEvent,
changeListener,
haveRegistered,
model,
pages,
tabPlacement,
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 | |
TabbedPane(UserGUI userGUI,
Player[] players,
int playerID)
Creates an instance of TabbedPane showing the icons and
names of all the players in the game, along with their initial scores,
in the "Scores" tab. |
|
| Method Summary | |
void |
addDeadTile(Tile tile)
Adds a dead tile to the scrollable client within the "Discards" tab. |
void |
clearDeadTiles()
Clears the scrollable client within the "Discards" tab of all dead tiles. |
static void |
main(java.lang.String[] args)
Driver code used for unit testing. |
private void |
showLeaveGameConfirmation()
Displays a dialog box asking the user to confirm their decision to leave the game and return to the game type selection screen. |
void |
updateScores(Player[] players)
Updates the scores for all the players present in the "Scores" tab. |
| Methods inherited from class javax.swing.JTabbedPane |
add,
add,
add,
add,
add,
addChangeListener,
addTab,
addTab,
addTab,
createChangeListener,
fireStateChanged,
getAccessibleContext,
getBackgroundAt,
getBoundsAt,
getComponentAt,
getDisabledIconAt,
getForegroundAt,
getIconAt,
getModel,
getSelectedComponent,
getSelectedIndex,
getTabCount,
getTabPlacement,
getTabRunCount,
getTitleAt,
getToolTipText,
getUI,
getUIClassID,
indexOfComponent,
indexOfTab,
indexOfTab,
insertTab,
isEnabledAt,
paramString,
remove,
removeAll,
removeChangeListener,
removeTabAt,
setBackgroundAt,
setComponentAt,
setDisabledIconAt,
setEnabledAt,
setForegroundAt,
setIconAt,
setModel,
setSelectedComponent,
setSelectedIndex,
setTabPlacement,
setTitleAt,
setUI,
updateUI,
writeObject |
| Methods inherited from class javax.swing.JComponent |
_paintImmediately,
|
| Methods inherited from class java.awt.Container |
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,
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 |
private UserGUI userGUI
UserGUI object.private javax.swing.JLabel[] playerLabel
players array supplied in the class constructor and in the
updateScores method.private javax.swing.JLabel[] scoreLabel
players array supplied in the class constructor and in the
updateScores method.private TabbedPane.DiscardsPane discardsPane
private TabbedPane.DiscardTileImage[] discardTileImages
discardsPane.| Constructor Detail |
public TabbedPane(UserGUI userGUI,
Player[] players,
int playerID)
TabbedPane showing the icons and
names of all the players in the game, along with their initial scores,
in the "Scores" tab. The name and score corresponding to the user is
uniquely displayed in a different colour.The scrollable client in the "Discards" tab displaying the dead tiles is initially empty.
TODO: Sound effects are not implemented in this version, so the "Enable sound effects" checkbox in the "Options" tab is disabled and permanently unchecked.
An ActionListener is added to the "Leave Game" button. This
will display a dialog box asking the user to confirm their decision to
leave the game and return to the game type selection screen.

userGUI - A reference to the parent UserGUI object.players - An array which stores information specific for each of
the players. In this method, we are interested only in
extracting the players' icons, names and scores from
this array.playerID - The array index that refers to the user's entry in the
players array. Since there are a maximum of
four players in a game of Mahjong, this value is in the
range [0,3].| Method Detail |
public void updateScores(Player[] players)
scoreLabel array.players - An array which stores information specific for each of
the players. In this method, we are interested only in
extracting the players' names and scores from this
array.public void addDeadTile(Tile tile)
discardsPane and adds to it a single tile image. The tile
is always added to the top row of the discardsPane. The
tiles already present in the pane will be shifted down. This eliminates
the need for the user to scroll down.tile - The dead tile to be added to the scrollable client.public void clearDeadTiles()
discardsPane and effectively resets this pane to its
initial (empty) state.private void showLeaveGameConfirmation()
public static void main(java.lang.String[] args)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||