Class MainFrame

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--MainFrame

public class MainFrame
extends JFrame

This class represents the frame/window that the game is played in. It mainly
just organizes other things. It gives you methods to access the timer and the
display. The timer is a javax.swing.Timer and you can use it to pause the
game by calling its stop method then restart the game by calling start or
restart on it. The Display can be used for many things, but most imporantly,
you will want to give it back focus after the user has clicked on another
part of the GUI is the game is running. You can also use the getClickLocation
method of the display to get a Location that represents where a mouse position
from a click or move was related to.


Fields inherited from class javax.swing.JFrame
EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled, accessibleContext

Fields inherited from class java.awt.Frame
DEFAULT_CURSOR, CROSSHAIR_CURSOR, TEXT_CURSOR, WAIT_CURSOR, SW_RESIZE_CURSOR, SE_RESIZE_CURSOR, NW_RESIZE_CURSOR, NE_RESIZE_CURSOR, N_RESIZE_CURSOR, S_RESIZE_CURSOR, W_RESIZE_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, MOVE_CURSOR, NORMAL, ICONIFIED

Fields inherited from class java.awt.Component
TOP_ALIGNMENT, CENTER_ALIGNMENT, BOTTOM_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT

Constructor Summary
MainFrame()
          Setup the GUI.

Method Summary
 MainDisplaygetDisplay()
          This returns the display object for the frame.
 TimergetTimer()
          This method returns that javax.swing.Timer object that is used to keep
the game going.

Methods inherited from class javax.swing.JFrame
frameInit, createRootPane, processKeyEvent, processWindowEvent, setDefaultCloseOperation, getDefaultCloseOperation, update, setJMenuBar, getJMenuBar, isRootPaneCheckingEnabled, setRootPaneCheckingEnabled, addImpl, remove, setLayout, getRootPane, setRootPane, getContentPane, setContentPane, getLayeredPane, setLayeredPane, getGlassPane, setGlassPane, paramString, getAccessibleContext

Methods inherited from class java.awt.Frame
finalize, addNotify, getTitle, setTitle, getIconImage, setIconImage, getMenuBar, setMenuBar, isResizable, setResizable, setState, getState, remove, removeNotify, setCursor, getCursorType, getFrames

Methods inherited from class java.awt.Window
pack, show, hide, dispose, toFront, toBack, getToolkit, getWarningString, getLocale, getInputContext, setCursor, getOwner, getOwnedWindows, addWindowListener, removeWindowListener, getListeners, processEvent, getFocusOwner, postEvent, isShowing, applyResourceBundle, applyResourceBundle, getGraphicsConfiguration

Methods inherited from class java.awt.Container
getComponentCount, countComponents, getComponent, getComponents, getInsets, insets, add, add, add, add, add, remove, removeAll, getLayout, doLayout, layout, invalidate, validate, validateTree, setFont, getPreferredSize, preferredSize, getMinimumSize, minimumSize, getMaximumSize, getAlignmentX, getAlignmentY, paint, print, paintComponents, printComponents, addContainerListener, removeContainerListener, processContainerEvent, deliverEvent, getComponentAt, locate, getComponentAt, findComponentAt, findComponentAt, isAncestorOf, list, list

Methods inherited from class java.awt.Component
getName, setName, getParent, getPeer, setDropTarget, getDropTarget, getTreeLock, isValid, isDisplayable, isVisible, isEnabled, setEnabled, enable, enable, disable, isDoubleBuffered, enableInputMethods, setVisible, show, getForeground, setForeground, getBackground, setBackground, getFont, setLocale, getColorModel, getLocation, getLocationOnScreen, location, setLocation, move, setLocation, getSize, size, setSize, resize, setSize, resize, getBounds, bounds, setBounds, reshape, setBounds, getX, getY, getWidth, getHeight, getBounds, getSize, getLocation, isOpaque, isLightweight, getGraphics, getFontMetrics, getCursor, paintAll, repaint, repaint, repaint, repaint, printAll, imageUpdate, createImage, createImage, prepareImage, prepareImage, checkImage, checkImage, contains, inside, contains, dispatchEvent, addComponentListener, removeComponentListener, addFocusListener, removeFocusListener, addHierarchyListener, removeHierarchyListener, addHierarchyBoundsListener, removeHierarchyBoundsListener, addKeyListener, removeKeyListener, addMouseListener, removeMouseListener, addMouseMotionListener, removeMouseMotionListener, addInputMethodListener, removeInputMethodListener, getInputMethodRequests, enableEvents, disableEvents, coalesceEvents, processComponentEvent, processFocusEvent, processMouseEvent, processMouseMotionEvent, processInputMethodEvent, processHierarchyEvent, processHierarchyBoundsEvent, handleEvent, mouseDown, mouseDrag, mouseUp, mouseMove, mouseEnter, mouseExit, keyDown, keyUp, action, gotFocus, lostFocus, isFocusTraversable, requestFocus, transferFocus, nextFocus, hasFocus, add, toString, list, list, list, addPropertyChangeListener, removePropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, firePropertyChange, setComponentOrientation, getComponentOrientation

Methods inherited from class java.lang.Object
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait

Constructor Detail

MainFrame

public MainFrame()
Setup the GUI.
Method Detail

getDisplay

public MainDisplay getDisplay()
This returns the display object for the frame. This should be used for
two main reasons. First, you should call requestFocus on this object
when something else (like a button or menu) has taken focus from it.
Second, you can use getClickLocation to find out the screen coordinates
of a mouse event.
Returns: The MainDisplay object shown in this frame.

getTimer

public Timer getTimer()
This method returns that javax.swing.Timer object that is used to keep
the game going. Each tick of the game is one firing of the timer. You
can use this to pause the game if that is needed for your gameplay.
Returns: The timer for the game so that delays or pausing can be altered.

Association Links

to Class MainDisplay

to Class javax.swing.Timer