|
||||||||
| 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
|
+--java.awt.Window
|
+--java.awt.Frame
|
+--javax.swing.JFrame
|
+--au.com.solidsoftware.multimahjong.mmc.usergui.UserGUI
This class contains the main method and is responsible for starting a game on the MultiMahjongClient, after which it serves as a centralised compartment for the storage of references to other specialised GUI-related classes.
During the early stages of the program, this class is responsible for displaying internal frames within the desktop pane. Three different internal frames have been envisaged, only one of which may be displayed at any one time:
The above internal frames will obtain information necessary for starting a game on this client. Such information will be obtained locally from the user via input fields, or remotely by connecting to the MultiMahjongServer. AGame object is created with the information obtained.
The UserGUI class then creates the playing screen, which allows
the user to interact graphically with the underlying game engine. The
playing screen will be an ordinary panel occupying the entire window, in
contrast to the internal frames described above. A typical view of the
playing screen is shown here:

After all initialisation is completed, the UserGUI class serves
as a centralised compartment for the storage and retrieval of references to
other specialised GUI-related classes. The advantage of this design is that
all the references are kept in the one place, meaning that individual
classes do not have to keep a whole list of their own references.
| Inner classes inherited from class javax.swing.JFrame |
javax.swing.JFrame.AccessibleJFrame |
| Inner classes inherited from class java.awt.Component |
java.awt.Component.AWTTreeLock |
| Field Summary | |
private ActionPane |
actionPane
A reference to the action pane. |
private javax.swing.JDesktopPane |
desktop
A specialised pane for the management of internal frames. |
private Game |
game
A reference to the game. |
private GameTypeSelector |
gameTypeSelector
A reference to game type selector. |
static javax.swing.ImageIcon[] |
iconList
An array of all the player icons used in the game. |
private static int |
ICONS
The number of icons we have in the iconImages/ directory. |
private int |
limit
The score limit of the game. |
private PlayArea |
playArea
A reference to the play area. |
private Human |
player
A reference to the Human object containing information
about the user. |
private int |
progress
This tracks the loading progress of the game and usergui classes. |
private javax.swing.JProgressBar |
progressBar
This shows the progress of the loading of the panes in the playing screen. |
private javax.swing.JLabel |
progressLabel
This displays what is actually loading at any given time. |
private StatusPane |
statusPane
A reference to the status pane. |
private TabbedPane |
tabbedPane
A reference to the tabbed pane. |
private UserGUI |
userGUI
A reference to this object. |
private int |
userID
The array index that refers to the user's entry in players
array. |
| Fields inherited from class javax.swing.JFrame |
accessibleContext,
defaultCloseOperation,
rootPane,
rootPaneCheckingEnabled |
| Fields inherited from class java.awt.Frame |
base,
CROSSHAIR_CURSOR,
DEFAULT_CURSOR,
E_RESIZE_CURSOR,
frameSerializedDataVersion,
HAND_CURSOR,
icon,
ICONIFIED,
mbManagement,
menuBar,
MOVE_CURSOR,
N_RESIZE_CURSOR,
nameCounter,
NE_RESIZE_CURSOR,
NORMAL,
NW_RESIZE_CURSOR,
ownedWindows,
resizable,
S_RESIZE_CURSOR,
SE_RESIZE_CURSOR,
serialVersionUID,
state,
SW_RESIZE_CURSOR,
TEXT_CURSOR,
title,
W_RESIZE_CURSOR,
WAIT_CURSOR,
weakThis |
| Fields inherited from class java.awt.Window |
active,
base,
focusMgr,
inputContext,
nameCounter,
OPENED,
ownedWindowList,
serialVersionUID,
state,
warningString,
weakThis,
windowListener,
windowSerializedDataVersion |
| 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 | |
UserGUI()
Creates an instance of UserGUI, initialising and displaying
the main application window. |
|
| Method Summary | |
void |
createGameTypeSelector()
Creates and displays a new internal frame that allows the user to select the type of game to play, to enter their name and icon, to set the score limit of the game, and to enter the address of the MultiMahjongServer. |
void |
createMultiGameJoiner(java.lang.String name,
int iconID,
Registrar registrar)
Creates and displays a new internal frame that forms a connection to the server and allows the user to select a game to join from a list of available multi player games on the server. |
void |
createMultiGameStarter(java.lang.String name,
int iconID,
int limit,
Registrar registrar)
Creates and displays a new internal frame that forms a connection to the server and allows the user to monitor the players that have registered to join the current multi player game. |
Player[] |
createPlayers(RefereeIntf referee,
int playerID,
int initScore)
Retrieves a list of players from the server, and create local Human, ComputerOpponent and Player
objects as appropriate. |
void |
createPlayingScreen(Player[] players)
Displays the playing screen. |
ActionPane |
getActionPane()
Access method - returns a reference to the action pane. |
Game |
getGame()
Access method - returns a reference to the game. |
GameTypeSelector |
getGameTypeSelector()
Access method - returns a reference to the game type selector. |
PlayArea |
getPlayArea()
Access method - returns a reference to the play area. |
Human |
getPlayer()
Access method - returns a reference to the Human object
containing information about the user. |
StatusPane |
getStatusPane()
Access method - returns a reference to the status pane. |
TabbedPane |
getTabbedPane()
Access method - returns a reference to the tabbed pane. |
static void |
main(java.lang.String[] args)
Main method of the MultiMahjongClient application. |
void |
startGame(RefereeIntf referee,
Observer observer,
int playerID)
Creates a multi player game on this client. |
void |
startGame(java.lang.String name,
int iconID,
int limit)
Creates a single player game on this client. |
| Methods inherited from class javax.swing.JFrame |
addImpl,
createRootPane,
createRootPaneException,
frameInit,
getAccessibleContext,
getContentPane,
getDefaultCloseOperation,
getGlassPane,
getJMenuBar,
getLayeredPane,
getRootPane,
isRootPaneCheckingEnabled,
paramString,
processKeyEvent,
processWindowEvent,
setContentPane,
setDefaultCloseOperation,
setGlassPane,
setJMenuBar,
setLayeredPane,
setLayout,
setRootPane,
setRootPaneCheckingEnabled,
update |
| Methods inherited from class java.awt.Frame |
|
| Methods inherited from class java.awt.Window |
addOwnedWindow,
addWindowListener,
applyResourceBundle,
applyResourceBundle,
connectOwnedWindow,
dispatchEventImpl,
dispose,
eventEnabled,
getFocusOwner,
getInputContext,
getLocale,
getOwnedWindows,
getOwner,
getToolkit,
getWarningString,
isActive,
isShowing,
nextFocus,
ownedInit,
pack,
postEvent,
postWindowEvent,
preProcessKeyEvent,
processEvent,
removeOwnedWindow,
removeWindowListener,
setFocusOwner,
setWarningString,
show,
toBack,
toFront,
transferFocus |
| Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
applyOrientation,
countComponents,
deliverEvent,
dispatchEventToSelf,
doLayout,
findComponentAt,
findComponentAt,
getAlignmentX,
getAlignmentY,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents_NoClientCode,
getComponents,
getInsets,
getLayout,
getMaximumSize,
getMinimumSize,
getMouseEventTarget,
getPreferredSize,
getWindow,
insets,
invalidate,
invalidateTree,
isAncestorOf,
layout,
lightweightPrint,
list,
list,
locate,
minimumSize,
paint,
paintComponents,
postsOldMouseEvents,
preferredSize,
print,
printComponents,
printOneComponent,
processContainerEvent,
proxyEnableEvents,
proxyRequestFocus,
remove,
remove,
removeAll,
removeContainerListener,
setFont,
validate,
validateTree |
| Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addPropertyChangeListener,
addPropertyChangeListener,
areInputMethodsEnabled,
bounds,
checkImage,
checkImage,
coalesceEvents,
contains,
contains,
createImage,
createImage,
disable,
disableEvents,
dispatchEvent,
enable,
enable,
enableEvents,
enableInputMethods,
firePropertyChange,
getBackground,
getBounds,
getBounds,
getColorModel,
getComponentOrientation,
getCursor,
getDropTarget,
getFont_NoClientCode,
getFont,
getFontMetrics,
getForeground,
getGraphics,
getHeight,
getInputMethodRequests,
getLocation,
getLocation,
getLocationOnScreen,
getName,
getNativeContainer,
getParent_NoClientCode,
getParent,
getPeer,
getSize,
getSize,
getToolkitImpl,
getTreeLock,
getWidth,
getWindowForObject,
getX,
getY,
gotFocus,
handleEvent,
hasFocus,
hide,
imageUpdate,
inside,
isDisplayable,
isDoubleBuffered,
isEnabled,
isEnabledImpl,
isFocusTraversable,
isLightweight,
isOpaque,
isValid,
isVisible,
keyDown,
keyUp,
list,
list,
list,
location,
lostFocus,
mouseDown,
mouseDrag,
mouseEnter,
mouseExit,
mouseMove,
mouseUp,
move,
nextFocus,
paintAll,
prepareImage,
prepareImage,
printAll,
processComponentEvent,
processFocusEvent,
processInputMethodEvent,
processMouseEvent,
processMouseMotionEvent,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removePropertyChangeListener,
removePropertyChangeListener,
repaint,
repaint,
repaint,
repaint,
requestFocus,
reshape,
resize,
resize,
setBackground,
setBounds,
setBounds,
setComponentOrientation,
setCursor,
setDropTarget,
setEnabled,
setForeground,
setLocale,
setLocation,
setLocation,
setName,
setSize,
setSize,
setVisible,
show,
size,
toString,
transferFocus |
| Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
| Field Detail |
private UserGUI userGUI
private static final int ICONS
public static javax.swing.ImageIcon[] iconList
private javax.swing.JDesktopPane desktop
private GameTypeSelector gameTypeSelector
Registrar object on
the remote server.private TabbedPane tabbedPane
private ActionPane actionPane
private StatusPane statusPane
private PlayArea playArea
private int progress
private javax.swing.JLabel progressLabel
private javax.swing.JProgressBar progressBar
private Human player
Human object containing information
about the user.private Game game
private int limit
private int userID
players
array. Since there are a maximum of four players in a game of Mahjong,
this value is in the range [0,3].| Constructor Detail |
public UserGUI()
UserGUI, initialising and displaying
the main application window. A WindowListener is added to
this window that, upon intercepting a "Close Window" operation from the
operating system, displays a dialog box asking the user to confirm their
decision to quit the program.TODO: screenshot of the quit confirmation dialog
The player icon images will then be pre-loaded into an
public static array, available for ready retrieval by all
methods. Finally, the createGameTypeSelector method is
invoked, which creates and displays an internal frame in the centre of
main application window.
| Method Detail |
public void createGameTypeSelector()
GameTypeSelector
is then created and added to the desktop pane. The loading of the
GameTypeSelector occurs in a separate thread so that the
GUI does not appears "frozen" to the user.
public void createMultiGameStarter(java.lang.String name,
int iconID,
int limit,
Registrar registrar)
MultiGameStarter and adding this to the
desktop pane. The loading of the MultiGameStarter occurs in
a separate thread so that the GUI does not appears "frozen" to the
user.name - the name of the usericonID - the iconID of the userlimit - the score limitregistrar - the name of the remote registrar
public void createMultiGameJoiner(java.lang.String name,
int iconID,
Registrar registrar)
MultiGameJoiner and adding this to
the desktop pane. The loading of the GameTypeSelector
occurs in a separate thread so that the GUI does not appears "frozen"
to the user.name - the name of the usericonID - the iconID of the userregistrar - the name of the remote registrar
public void startGame(java.lang.String name,
int iconID,
int limit)
Observer and then sets up a LocalReferee
using this new Observer. It then creates a new
Game which runs off this LocalReferee.
Upon creating each of the four players required for a game (who may be
either a Human, ComputerOpponent or
Player, the createPlayingScreen method is
invoked to create and display the main playing screen.name - the name of the usericonID - the iconID of the userlimit - the score limit
public void startGame(RefereeIntf referee,
Observer observer,
int playerID)
Game class with the supplied parameters.
The createPlayingScreen method is then invoked to create
and display the main playing screen. The generation of computer
opponents, the randomisation of the seating posiitons of all the
players, and the determination of the initial winds of all the players
have already been accomplished - and all this information is present
within the players array.referee - The remote referee.observer - The local observer.playerID - The unique player identification number.
public Player[] createPlayers(RefereeIntf referee,
int playerID,
int initScore)
Human, ComputerOpponent and Player
objects as appropriate. The decision as to the class of the object to be
created is based solely on the positions array being
obtained from the server.referee - The local server that simulates the behaviour of
the functionality of the remote server.playerID - The unique player identification number.initScore - The initial score of each of the four players.public void createPlayingScreen(Player[] players)
players - An array which stores information specific for each of
the players. In this method, we are interested only in
extracting the players' names, scores and icons.public GameTypeSelector getGameTypeSelector()
public TabbedPane getTabbedPane()
public ActionPane getActionPane()
public StatusPane getStatusPane()
public PlayArea getPlayArea()
public Human getPlayer()
Human object
containing information about the user.Human object containing
information about the userpublic Game getGame()
public static void main(java.lang.String[] args)
UserGUI.args - Any command line arguments supplied. This parameter is
ignored by this method.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||