Class SGui

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--SGui
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class SGui
extends javax.swing.JFrame
implements java.awt.event.ActionListener

The SGui class is the Graphical User Interface for the Sokoban program

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Inner classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Inner classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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
protected  javax.swing.JTextField chatInput
           
protected  javax.swing.JPanel chatPanel
           
protected  javax.swing.JTextArea chatText
           
protected  javax.swing.JButton continueButton
           
protected static boolean debugMode
          The debug flag signifying if the game should return time accurately or always 1.
protected  javax.swing.JMenuItem gameEndGame
           
protected  javax.swing.JMenuItem gameExit
           
protected  javax.swing.JMenuItem gameHighScores
           
protected  javax.swing.JMenuItem gameLevelEditor
           
protected  javax.swing.JMenuItem gameLoad
           
protected  javax.swing.JMenu gameMenu
           
protected  javax.swing.JMenu gameNewGame
           
protected  javax.swing.JMenuItem gameNewMultiplayerGame
           
protected  javax.swing.JMenuItem gameNewSoloGame
           
protected  javax.swing.JMenuItem gameOptChange
           
protected  javax.swing.JMenu gameOptions
           
protected  javax.swing.JMenuItem gameSave
           
protected  javax.swing.JMenuItem helpAbout
           
protected  javax.swing.JMenuItem helpInstructions
           
protected  javax.swing.JMenu helpMenu
           
protected  javax.swing.JMenuItem helpTutorial
           
protected  SGui.KeyMonitor keyboardListener
          Instance of KeyMonitor to listen to keyboard commands to control the robot while the game is being played.
protected  javax.swing.JMenuItem levelEditorExit
           
protected  javax.swing.JMenuItem levelEditorHelpInstructions
           
protected  javax.swing.JMenu levelEditorHelpMenu
           
protected  javax.swing.JMenu levelEditorLevelMenu
           
protected  javax.swing.JMenuItem levelEditorLoad
           
protected  javax.swing.JMenuItem levelEditorNew
           
protected  javax.swing.JMenuItem levelEditorOrg
           
protected  javax.swing.JMenuItem levelEditorSave
           
protected  javax.swing.JMenuItem levelGoTo
           
protected  javax.swing.JMenu levelMenu
           
protected  javax.swing.JMenuItem levelNext
           
protected  javax.swing.JMenuItem levelPause
           
protected  javax.swing.JMenuItem levelPrevious
           
protected  javax.swing.JMenuItem levelReplay
           
protected  javax.swing.JMenuItem levelRestart
           
protected  javax.swing.JLabel levelScore
           
protected  javax.swing.JMenuItem levelUndo
           
protected  javax.swing.JButton mainHighScores
           
protected  javax.swing.JButton mainLevelEditor
           
protected  javax.swing.JButton mainMulti
           
protected  javax.swing.JButton mainSolo
           
protected  javax.swing.JPanel mapDisplay
          The display panel where the MapRenderer will be drawn.
protected  javax.swing.JMenuBar menuBar
           
protected  javax.swing.JLabel pauseScreen
          The pause screen message.
protected  javax.swing.JButton sendChat
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SGui(boolean debugFlag)
          Constructor - initializes the window and displays the start screen
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Handles the events passed to the Sokoban class ActionListener.
 void addKeyMonitor()
          Adds a KeyMonitor
 void addText(java.lang.String str)
          Displays the passed text in the chat window
 void endGame()
          Ends the game and stops the statsMonitor Timer.
 void loadGame()
          Show the load game dialog box.
 void loadMainMenu()
          Change the topPanel to display the main menu.
 void pauseGame()
          Disable the UI buttons not available during a pause game.
 void removeKeyMonitor()
          Removes all KeyMonitors
 void resetStatDisplay()
          Resets the stat display.
 void resumeGame()
          Enable the UI buttons disabled after a pause game.
 void setLevelFinishedDisplay(int levelScore)
          Displays the level finished screen giving the user's game statistics
 void setLevelName(java.lang.String name)
          Changes the level name displayed to the user.
 void setMapVisible()
          Change the game display to show the map.
 void setPauseDisplay()
          Change the game display to show the pause screen and the map.
 java.lang.String showGoToDialog()
          Show the go to level dialog box.
 void showHelpDialog(java.lang.String helpFile)
          Show a dialog box displaying the instructions text file.
 void startGame(boolean multiplayer)
          Initializes the topPanel to begin displaying the map.
 void updateStats()
          Updates the stat display.
protected  void viewHighScores()
          Displays the High Scores window
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, isResizable, remove, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, dispose, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isShowing, pack, postEvent, processEvent, removeWindowListener, setCursor, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, 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, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, 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, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

debugMode

protected static boolean debugMode
The debug flag signifying if the game should return time accurately or always 1.

menuBar

protected javax.swing.JMenuBar menuBar

gameMenu

protected javax.swing.JMenu gameMenu

gameNewGame

protected javax.swing.JMenu gameNewGame

gameNewSoloGame

protected javax.swing.JMenuItem gameNewSoloGame

gameNewMultiplayerGame

protected javax.swing.JMenuItem gameNewMultiplayerGame

gameLoad

protected javax.swing.JMenuItem gameLoad

gameSave

protected javax.swing.JMenuItem gameSave

gameOptions

protected javax.swing.JMenu gameOptions

gameOptChange

protected javax.swing.JMenuItem gameOptChange

gameHighScores

protected javax.swing.JMenuItem gameHighScores

gameLevelEditor

protected javax.swing.JMenuItem gameLevelEditor

gameEndGame

protected javax.swing.JMenuItem gameEndGame

gameExit

protected javax.swing.JMenuItem gameExit

levelMenu

protected javax.swing.JMenu levelMenu

levelNext

protected javax.swing.JMenuItem levelNext

levelPrevious

protected javax.swing.JMenuItem levelPrevious

levelGoTo

protected javax.swing.JMenuItem levelGoTo

levelRestart

protected javax.swing.JMenuItem levelRestart

levelPause

protected javax.swing.JMenuItem levelPause

levelUndo

protected javax.swing.JMenuItem levelUndo

levelReplay

protected javax.swing.JMenuItem levelReplay

helpMenu

protected javax.swing.JMenu helpMenu

helpInstructions

protected javax.swing.JMenuItem helpInstructions

helpTutorial

protected javax.swing.JMenuItem helpTutorial

helpAbout

protected javax.swing.JMenuItem helpAbout

mainSolo

protected javax.swing.JButton mainSolo

mainMulti

protected javax.swing.JButton mainMulti

mainHighScores

protected javax.swing.JButton mainHighScores

mainLevelEditor

protected javax.swing.JButton mainLevelEditor

continueButton

protected javax.swing.JButton continueButton

levelScore

protected javax.swing.JLabel levelScore

chatPanel

protected javax.swing.JPanel chatPanel

chatText

protected javax.swing.JTextArea chatText

chatInput

protected javax.swing.JTextField chatInput

sendChat

protected javax.swing.JButton sendChat

levelEditorLevelMenu

protected javax.swing.JMenu levelEditorLevelMenu

levelEditorHelpMenu

protected javax.swing.JMenu levelEditorHelpMenu

levelEditorNew

protected javax.swing.JMenuItem levelEditorNew

levelEditorLoad

protected javax.swing.JMenuItem levelEditorLoad

levelEditorSave

protected javax.swing.JMenuItem levelEditorSave

levelEditorOrg

protected javax.swing.JMenuItem levelEditorOrg

levelEditorExit

protected javax.swing.JMenuItem levelEditorExit

levelEditorHelpInstructions

protected javax.swing.JMenuItem levelEditorHelpInstructions

mapDisplay

protected javax.swing.JPanel mapDisplay
The display panel where the MapRenderer will be drawn.

pauseScreen

protected javax.swing.JLabel pauseScreen
The pause screen message.

keyboardListener

protected SGui.KeyMonitor keyboardListener
Instance of KeyMonitor to listen to keyboard commands to control the robot while the game is being played.
Constructor Detail

SGui

public SGui(boolean debugFlag)
Constructor - initializes the window and displays the start screen
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Handles the events passed to the Sokoban class ActionListener.
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - an event passed to the ActionListener.

Pre-conditions:an event has occured.

Post-conditions:the Game class has been informed of the change and the user interface has been updated.


startGame

public void startGame(boolean multiplayer)
Initializes the topPanel to begin displaying the map.
Parameters:
multiplayer - signifies if the game is multiplayer and the chat box should be included or not

Pre-conditions:none.

Post-conditions:the Game class has been initialized and the game begins.


loadMainMenu

public void loadMainMenu()
Change the topPanel to display the main menu.
preconditions: none
postconditions: the main menu is displayed to the user

loadGame

public void loadGame()
Show the load game dialog box. If a game is loaded, change the display to show the map.
preconditions: none
postconditions: the go to level dialog is displayed

endGame

public void endGame()
Ends the game and stops the statsMonitor Timer.

Pre-conditions:a game is currently in progress.

Post-conditions:the statsMonitor has been stopped and the game has ended.


showGoToDialog

public java.lang.String showGoToDialog()
Show the go to level dialog box.
preconditions: none
postconditions: the go to level dialog is displayed

showHelpDialog

public void showHelpDialog(java.lang.String helpFile)
Show a dialog box displaying the instructions text file.
preconditions: none
postconditions: the instructions dialog is displayed

addKeyMonitor

public void addKeyMonitor()
Adds a KeyMonitor

removeKeyMonitor

public void removeKeyMonitor()
Removes all KeyMonitors

setLevelFinishedDisplay

public void setLevelFinishedDisplay(int levelScore)
Displays the level finished screen giving the user's game statistics
Parameters:
levelScore - the score received for finishing the level

Pre-conditions:a level has been finished.

Post-conditions:the level finished screen is displayed to the user.


pauseGame

public void pauseGame()
Disable the UI buttons not available during a pause game.
preconditions: none
postconditions: the UI buttons not available when a game is paused are disabled

resumeGame

public void resumeGame()
Enable the UI buttons disabled after a pause game.
preconditions: none
postconditions: the UI buttons not available when a game is paused are enabled

updateStats

public void updateStats()
Updates the stat display.
preconditions: the game is running
postconditions: the stats are updated to reflect the current state of the game

resetStatDisplay

public void resetStatDisplay()
Resets the stat display.
preconditions: none
postconditions: the stats are set to how they were at the beginning of the game

setPauseDisplay

public void setPauseDisplay()
Change the game display to show the pause screen and the map.
preconditions: the map is being displayed
postconditions: the map is removed and the pause screen is being displayed

setMapVisible

public void setMapVisible()
Change the game display to show the map.
preconditions: none
postconditions: the map is displayed

setLevelName

public void setLevelName(java.lang.String name)
Changes the level name displayed to the user.
Parameters:
name - the new level name to display to the user

Pre-conditions:the level has been changed.

Post-conditions:the level name displayed to the user is updated.


addText

public void addText(java.lang.String str)
Displays the passed text in the chat window

viewHighScores

protected void viewHighScores()
Displays the High Scores window