|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
ballwar.view.BallGUI
public class BallGUI
A subclass of JFrame containing the various GUI components specified in the program behavior specification. Allows the balls to be specified, constructed, drawn and controlled. Allows players to be specified and the game to be controlled. Provides a Container area where the drawing object is to be drawn.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JFrame |
---|
JFrame.AccessibleJFrame |
Nested classes/interfaces inherited from class java.awt.Frame |
---|
Frame.AccessibleAWTFrame |
Nested classes/interfaces inherited from class java.awt.Window |
---|
Window.AccessibleAWTWindow |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
private JButton |
_addBtn
Button to add the strategy entered in inputTF to both drop lists. |
private JButton |
_addPaintBtn
Button to add the paint strategy entered in _paintTF to the drop list. |
private IBallCreateAdapter |
_bCreateA
IBallCreateAdapater used to create new balls. |
private IBallCtrlAdapter |
_bCtrlA
The IBallCtrlAdapter used to control the balls. |
private JPanel |
_canvasPnl
The panel upon which the balls are painted. |
private JPanel |
_cbPnl
The sub-panel that holds the drop-lists of strategies and their control buttons. |
private JButton |
_clearAllBtn
The button to clear all the balls. |
private JButton |
_combineBtn
Button used to combine a selection from _list1CBox and a selection from _list2BCBox into a combined strategy. |
private JPanel |
_controlPnl
The panel upon which all the game controls are located. |
private IGameCtrlAdapter |
_gCtrlA
The IGameCtrlAdapter used to control the game. |
private JPanel |
_inputPnl
The sub-panel that the input textfield is located. |
private JTextField |
_inputTF
The textfield where the user can type in the classname of a new strategy. |
private JComboBox |
_list1CBox
A drop-list with all the strategies and combinations of strategies. |
private JComboBox |
_list2CBox
Same content as _list1CBox because two lists are needed to create combinations of strategies. |
private JButton |
_makePlayerBtn
Button to make a new player with the name typed in by the user. |
private JButton |
_makeSelectedBtn
Button to make a ball with the selected strategy in _list1CBox. |
private JButton |
_makeSwitcherBtn
The button that makes a new ball with a SwitcherStrategy. |
private JComboBox |
_paintCBox
Drop list with available paint strategies. |
private JPanel |
_paintSelPnl
The sub-panel that the paint selection controls are located. |
private JTextField |
_paintTF
The textfield where the user can type in the classname of a new painting strategy. |
private JComboBox |
_playersCBox
Drop list that shows the names of all the players made so far. |
private JLabel |
_statusLbl
Label at the bottom of the screen used to display the status of the game and the player's scores. |
private JButton |
_switchBtn
The button that switches the decoree in the SwitcherStrategy to the currently selected strategey. |
private JPanel |
_switcherPnl
The sub-panel that holds the SwitcherStrategy controls. |
private static long |
serialVersionUID
|
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 | |
---|---|
BallGUI(WindowListener wl,
IBallCreateAdapter bCreateA,
IBallCtrlAdapter bCtrlA,
IGameCtrlAdapter gCtrlA)
Constructor for the class. |
Method Summary | |
---|---|
void |
addComponent(Component c)
Adds the given Component to the control panel. |
void |
addKeyCmd(String keyName,
ILambda cmd)
Adds the given key such that whenever that key is pressed the given command (AbstractAction) is performed. |
void |
autoWidth()
Automatically adjusts the width of the GUI to its minimum size such that all the controls can be seen. |
Container |
getCanvas()
Accessor method for the panel upon which the balls are to be drawn |
Object |
getSelectedPlayer()
Returns the selected player (held in a drop list) . |
private void |
init()
Initializes and lays out the GUI components. |
void |
update()
Updates the view. |
Methods inherited from class java.awt.Frame |
---|
addNotify, 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.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.MenuContainer |
---|
getFont, postEvent |
Field Detail |
---|
private static final long serialVersionUID
private JPanel _controlPnl
private JPanel _canvasPnl
private JButton _clearAllBtn
private JTextField _inputTF
private JButton _addBtn
private JPanel _inputPnl
private JButton _makeSwitcherBtn
private JButton _switchBtn
private JPanel _switcherPnl
private JPanel _cbPnl
private JComboBox _list1CBox
private JComboBox _list2CBox
private JButton _combineBtn
private JButton _makeSelectedBtn
private JLabel _statusLbl
private JButton _makePlayerBtn
private JComboBox _playersCBox
private JTextField _paintTF
private JPanel _paintSelPnl
private JButton _addPaintBtn
private JComboBox _paintCBox
private IBallCtrlAdapter _bCtrlA
private IGameCtrlAdapter _gCtrlA
private IBallCreateAdapter _bCreateA
Constructor Detail |
---|
public BallGUI(WindowListener wl, IBallCreateAdapter bCreateA, IBallCtrlAdapter bCtrlA, IGameCtrlAdapter gCtrlA)
wl
- The WindowListener called when this window closes.bCreateA
- The IBallCreateAdapter used to create the balls.bCtrlA
- The IBallCtrlAdapter used to control the balls.gCtrlA
- The IGameCtrlAdapter used to control the game.Method Detail |
---|
private void init() throws Exception
Exception
public void autoWidth()
public Container getCanvas()
public void update()
public void addKeyCmd(String keyName, ILambda cmd)
keyName
- The name of the virtual key to add, minus the leading "VK_".
See the Java documentation under "KeyEvent".cmd
- The behavior to associate with this key. The command's
actionPerformed() method will be called whenever the given key
is pressed.public Object getSelectedPlayer()
public void addComponent(Component c)
c
- The component to add.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |