net.slashie.libjcsi.textcomponents
Class MenuBox

java.lang.Object
  extended by net.slashie.libjcsi.textcomponents.TextComponent
      extended by net.slashie.libjcsi.textcomponents.MenuBox
All Implemented Interfaces:
java.io.Serializable

public class MenuBox
extends TextComponent

Box used for various menus.

Author:
Santiago Zapata
See Also:
Serialized Form

Constructor Summary
MenuBox(ConsoleSystemInterface si)
          Creates a new menu.
 
Method Summary
 void draw()
          Prints the menu to the screen.
 java.lang.Object getSelection()
          Allows the user to move the selection bar up and down the menu and then select an item in the menu with the spacebar.
 void setBorder(boolean val)
          Sets whether or not there is a border on the menu.
 void setMenuItems(java.util.Vector items)
          Allows the menu items to be set.
 void setPosition(int x, int y)
          Allows the position of the menu's upper left corner to be specified.
 void setPrompt(java.lang.String prompt)
          Allows the prompt to be specified.
 void setPromptSize(int size)
          Sets the height of the menu.
 void setTitle(java.lang.String s)
           
 void setWidth(int width)
          Sets the width of the menu and resets the upper left position to reflect the change of width.
 
Methods inherited from class net.slashie.libjcsi.textcomponents.TextComponent
clearBox, drawBorder, getForeColor, getHeight, getWidth, hasBorder, setBorderColor, setBorderColor, setBounds, setForeColor, setForeColor, setHeight
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuBox

public MenuBox(ConsoleSystemInterface si)
Creates a new menu.

Parameters:
si - ConsoleSystemInterface menu is attached to.
Method Detail

setPosition

public void setPosition(int x,
                        int y)
Allows the position of the menu's upper left corner to be specified.

Overrides:
setPosition in class TextComponent
Parameters:
x - horizontal position
y - vertical position

setPromptSize

public void setPromptSize(int size)
Sets the height of the menu.

Parameters:
size - menu's height

setWidth

public void setWidth(int width)
Sets the width of the menu and resets the upper left position to reflect the change of width.

Overrides:
setWidth in class TextComponent
Parameters:
width - menu's width

setBorder

public void setBorder(boolean val)
Sets whether or not there is a border on the menu. The border draws inside the menu's dimensions.

Overrides:
setBorder in class TextComponent
Parameters:
val - true for a border

setPrompt

public void setPrompt(java.lang.String prompt)
Allows the prompt to be specified.

Parameters:
prompt - String to use as prompt.

setMenuItems

public void setMenuItems(java.util.Vector items)
Allows the menu items to be set.

Parameters:
items - Vector of the items in the menu.

draw

public void draw()
Prints the menu to the screen.

Specified by:
draw in class TextComponent

getSelection

public java.lang.Object getSelection()
Allows the user to move the selection bar up and down the menu and then select an item in the menu with the spacebar.

Returns:
item selected

setTitle

public void setTitle(java.lang.String s)
Parameters:
s - String that will be the title