GUI
Class GUI

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by GUI.GUI
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class GUI
extends javax.swing.JFrame
implements java.awt.event.WindowListener, java.awt.event.ActionListener

Class rensonsible for managing the whole graphical user interface of the program. The monopoly class interacts with the methods of this class in order to refresh the gui.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.JPanel CenterCell
           
protected  javax.swing.JPanel CenterCellPanel
           
protected  javax.swing.JLabel Mrmon
           
protected  Monopoly mygame
           
protected static java.util.ArrayList PlayersIcons
           
 javax.swing.JButton RollTab
           
 
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, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, 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
GUI(Monopoly game)
          Constructor of the GUI object.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Method invoked when user has clicked on the roll button.
 void buyHouse(int streetNmr, int numofhouses)
          Method invoked when a user would like to buy a house on a street.
 java.util.ArrayList getPlayers()
          Method used to return the private ArrayList PlayerNames.
 void mortageProperty(int propertyNmr)
          Method invoked when a user would like to mortage a property.
 void movePlayer(int playerid, int currPos, int des)
          Method responsible for depicting a player's move in the GUI grid.
 void refresh(int location, java.lang.String name, java.lang.String owner, int price, int rent, int housePrice)
          Method used when a change have occured in the content of an emerging menu.
 void refreshCP(java.lang.String ActiveName, int ActiveMon, java.lang.String NextName, int NextMon, int[] roll)
          Method rensponsible for refreshing the central panel of GUI when a change occures in one of it's components.
 void sellHouse(int streetNmr, int numofhouses)
          Method invoked when a user would like to sell a house from a street.
 void unmortageProperty(int propertyNmr)
          Method invoked when a user would like to unmortage a property.
 void windowActivated(java.awt.event.WindowEvent e)
          Method implemented only due to the fact that it is declared in the WindowListener Interface.
 void windowClosed(java.awt.event.WindowEvent e)
          Method implemented only due to the fact that it is declared in the WindowListener Interface.
 void windowClosing(java.awt.event.WindowEvent e)
          Method implemented due to the fact that it is declared in the WindowListener interface.
 void windowDeactivated(java.awt.event.WindowEvent e)
          Method implemented only due to the fact that it is declared in the WindowListener Interface.
 void windowDeiconified(java.awt.event.WindowEvent e)
          Method implemented only due to the fact that it is declared in the WindowListener Interface.
 void windowIconified(java.awt.event.WindowEvent e)
          Method implemented only due to the fact that it is declared in the WindowListener Interface.
 void windowOpened(java.awt.event.WindowEvent e)
          Method implemented only due to the fact that it is declared in the WindowListener Interface.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
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

RollTab

public final javax.swing.JButton RollTab

Mrmon

protected final javax.swing.JLabel Mrmon

CenterCell

protected javax.swing.JPanel CenterCell

CenterCellPanel

protected javax.swing.JPanel CenterCellPanel

PlayersIcons

protected static java.util.ArrayList PlayersIcons

mygame

protected Monopoly mygame
Constructor Detail

GUI

public GUI(Monopoly game)
Constructor of the GUI object. This Constructor first checks whether the screen resolution is acceptable via a call to the ScreenResError class, then it initializes the game's main frame and sets all players in the Start Cell.

Parameters:
game - the Monopoly object given to the constuctor in order gui to be able to get all the necessary information.
Method Detail

refreshCP

public void refreshCP(java.lang.String ActiveName,
                      int ActiveMon,
                      java.lang.String NextName,
                      int NextMon,
                      int[] roll)
Method rensponsible for refreshing the central panel of GUI when a change occures in one of it's components. Changes may occur only when player rolls dice, thus when the ActivePlayer name changes.

Parameters:
ActiveName - the Active Player's name.
ActiveMon - the Active Player's money.
NextName - the Next Player's name.
NextMon - the Next Player's money.
roll - the roll the Active Player rolled.

movePlayer

public void movePlayer(int playerid,
                       int currPos,
                       int des)
Method responsible for depicting a player's move in the GUI grid. This method also disables all the frame's menus to make sure that user won't cause any undesirably cause - effects. This method is in fact a thread to ensure that the repaint() method will executed.

Parameters:
playerid - the current player serial number, which determines which playericon will be moved.
currPos - the active player's current position, which determines from where the playericon will be removed.
des - the active player's final destination, which determines until which cell will the player be moved.

buyHouse

public void buyHouse(int streetNmr,
                     int numofhouses)
Method invoked when a user would like to buy a house on a street. This method calls the buy method in the corresponding Street cell.If this street has already 4 houses, then method add a hotel to it.
PRECONDITION : program must provide method with an acceptable cell serial number.
PRECONDITION : numofhouse variable value must be in [0,4]

Parameters:
streetNmr - the serial number of the cell user has choosen to buy a house on.
numofhouses - the numofhouses this street already has.

sellHouse

public void sellHouse(int streetNmr,
                      int numofhouses)
Method invoked when a user would like to sell a house from a street. This method calls the sell method in the corresponding Street cell. If this street has already a hotel, then method removes a hotel from it.
PRECONDITION : program must provide method with an acceptable cell serial number.
PRECONDITION : numofhouse variable value must be in [0,4]

Parameters:
streetNmr - the serial number of the cell user has choosen to buy a house on.
numofhouses - the numofhouses this street already has.

mortageProperty

public void mortageProperty(int propertyNmr)
Method invoked when a user would like to mortage a property. This method calls the mortage method in the corresponding cell (Street, TrainStation or company), to mortage it.
PRECONDITION : program must provide method with an acceptable cell serial number.

Parameters:
propertyNmr - the serial number of the cell user has choosen to mortage.

unmortageProperty

public void unmortageProperty(int propertyNmr)
Method invoked when a user would like to unmortage a property. This method calls the unmortage method in the corresponding cell (Street, TrainStation or company), to unmortage it.
PRECONDITION : progran must provide method with an acceptable cell serial number.

Parameters:
propertyNmr - the serial number of the cell user has choosen to unmortage.

refresh

public void refresh(int location,
                    java.lang.String name,
                    java.lang.String owner,
                    int price,
                    int rent,
                    int housePrice)
Method used when a change have occured in the content of an emerging menu. This can happen p.e. when user buys a house on a street (thus the rent price is increased). If one of the following parameteres is not specified by default (p.e. train stations don't include a housePrice field), then the game's design provides the emerging menu with value -1;

Parameters:
location - the serial number describing the cell for which the emerging menu's description is about to change.
name - the name of the Cell for which the emerging menu's desctription is about to change.
owner - the owner of the Cell for which the emerging menu's desctription is about to change.
price - the prive of the Cell for which the emerging menu's desctription is about to change.
rent - the rent of the Cell for which the emerging menu's desctription is about to change.
housePrice - the housePrice of the Cell for which the emerging menu's desctription is about to change.

getPlayers

public java.util.ArrayList getPlayers()
Method used to return the private ArrayList PlayerNames. If this ArrayList is null then method throws a NoPlayersInsertedException(), indicating that no players have been inserted.

Returns:
the PlayerNames ArrayList.
Throws:
NoPlayersInsertedException - if the PlayerNames ArrayList is null.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Method invoked when user has clicked on the roll button.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - The ActionEvent which has occured(user has clicked the roll button).

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
Method implemented due to the fact that it is declared in the WindowListener interface. This method manages the actions that are bound to happen when the program is about to exit (thus when user has clicked the x button in the main frame or the exit command in the menu.

Specified by:
windowClosing in interface java.awt.event.WindowListener
Parameters:
e - the WindowEvent which has occured.

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Method implemented only due to the fact that it is declared in the WindowListener Interface.

Specified by:
windowOpened in interface java.awt.event.WindowListener
Parameters:
e - the WindowEvent which has occured.

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Method implemented only due to the fact that it is declared in the WindowListener Interface.

Specified by:
windowClosed in interface java.awt.event.WindowListener
Parameters:
e - the WindowEvent which has occured.

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
Method implemented only due to the fact that it is declared in the WindowListener Interface.

Specified by:
windowActivated in interface java.awt.event.WindowListener
Parameters:
e - the WindowEvent which has occured.

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Method implemented only due to the fact that it is declared in the WindowListener Interface.

Specified by:
windowIconified in interface java.awt.event.WindowListener
Parameters:
e - the WindowEvent which has occured.

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Method implemented only due to the fact that it is declared in the WindowListener Interface.

Specified by:
windowDeiconified in interface java.awt.event.WindowListener
Parameters:
e - the WindowEvent which has occured.

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Method implemented only due to the fact that it is declared in the WindowListener Interface.

Specified by:
windowDeactivated in interface java.awt.event.WindowListener
Parameters:
e - the WindowEvent which has occured.