|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--waba.ui.Control | +--waba.ui.Container | +--waba.ui.Window | +--waba.ui.MenuBar
Constructs a Menu with the given items. The Menu supports disabled and checked items.
Here is an example of how to build the menu for the DateBook:
String col0[] = { "Record", // caption for the MenuBar "?NewEvent", // checked item "Delete Event...", "Attach Note", "Delete Note...", "Purge...", "*Beam Event", // disabled item }; String col1[] = { "Edit", // caption for the MenuBar "Undo", "Cut", "Copy", "Paste", "Select All", "-", // a dotted line "Keyboard", "Graffiti Help", }; String col2[] = { "Options", // caption for the MenuBar "Font...", "Preferences...", "Display Options...", "Phone Lookup", "About Date Book", }; setMenuBar(new MenuBar(new String[][]{col0,col1,col2}));An WINDOW_CLOSED event will be thrown when the menu is closed. The menu can be closed by a click on a valid item or clicking outside of its bounds. To discover why it was closed, see method getSelectedMenuItem.
Note that the separator dotted line don't generate events.
I know that storing things in String is very odd; I should create a class MenuItem and store things there; but this way is faster and uses less memory.
Field Summary | |
static char |
CHECKED
|
static char |
DISABLED
|
int |
gap
Note: if you want to change the spacement between the menu items (maybe to make more items fit in the row), change this gap value. |
static char |
UNCHECKED
|
Fields inherited from class waba.ui.Window |
beepIfOut,
borderStyle,
canDrag,
eraseBackgroundNow,
flicker,
HIDE_STATE,
highResPrepared,
imgCovered,
lastSwappedContainer,
mainSwapContainer,
menubar,
needsPaint,
NO_BORDER,
RECT_BORDER,
ROUND_BORDER,
TAB_BORDER,
TAB_ONLY_BORDER,
title,
titleFont,
topMost,
VK_BOTTOM,
VK_HIDE,
VK_TOP,
zStack |
Fields inherited from class waba.ui.Container |
BORDER_LOWERED,
BORDER_NONE,
BORDER_RAISED,
BORDER_SIMPLE,
children,
lastH,
lastW,
lastX,
lastY,
parentWindow,
tail |
Fields inherited from class waba.ui.Control |
AFTER,
appId,
asContainer,
asWindow,
backColor,
backDis,
BEFORE,
BOTTOM,
CENTER,
enabled,
FILL,
FIT,
fm,
fmH,
focusLess,
font,
foreColor,
foreDis,
height,
LEFT,
parent,
PREFERRED,
RANGE,
RIGHT,
SAME,
TOP,
visible,
width,
x,
x2,
y,
y2 |
Constructor Summary | |
MenuBar(String[][] items)
Create a MenuBar with the given items. |
Method Summary | |
int |
getSelectedMenuItem()
Returns the current menu item selected. |
boolean |
isCheckable(int menuItem)
Returns true if a menu item is checkable |
boolean |
isChecked(int menuItem)
Returns true if the given menu item in the xyy format is checked. |
boolean |
isEnabled(int menuItem)
Returns the enabled state of the given menu item. |
protected void |
loadBehindLastPopup(int ph)
|
protected boolean |
onClickedOutside(int x,
int y)
Close the popup list with a click outside its bounds |
protected void |
onColorsChanged(boolean colorsChanged)
Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container. |
void |
onEvent(Event event)
Called to process key, pen, control and other posted events. |
protected void |
onFontChanged()
Change the font and recompute some parameters |
void |
onPaint(Graphics g)
Draws the border (if any). |
protected void |
onPopup()
Setup some important variables |
protected void |
popupClosed(PopupMenu pop)
called from menu to tell that it is being closed |
protected void |
postPopup()
Placeholder called after the popup is done and after the repaint of this window. the default implementation does nothing. |
void |
setChecked(int menuItem,
boolean check)
Put a check in the given menu item in the xyy format. |
void |
setCursorColor(Color c)
Sets the cursor color. |
void |
setEnabled(int menuItem,
boolean enable)
Enable the given menu item. |
void |
setItems(String[][] items)
Sets the current Menu items. |
void |
setPopColors(Color back,
Color fore,
Color cursor)
Set the colors for the popup windows. |
void |
setVisible(boolean b)
Called by the Window class to popup this MenuBar |
protected void |
switchTo(int index)
|
Methods inherited from class waba.ui.Window |
_doPaint,
_doPaint,
_postEvent,
damageRect,
destroyZStack,
dontSaveBehind,
getClientRect,
getFocus,
getOffScreen,
getPreferredHeight,
getPreferredWidth,
getTopMost,
isTopMost,
isVisible,
loadBehind,
makeUnmovable,
onUnpop,
paintTitle,
popupBlockingModal,
popupMenuBar,
popupModal,
postUnpop,
pumpEvents,
saveBehind,
setBorderStyle,
setDoubleBuffer,
setFocus,
setMenuBar,
setStatePosition,
setTitle,
setTitleFont,
swap,
unpop,
validate |
Methods inherited from class waba.ui.Container |
add,
add,
add,
broadcastEvent,
findChild,
getChildren,
onStart,
paintChildren,
remove,
setEnabled |
Methods inherited from class waba.ui.Control |
addTimer,
contains,
createGraphics,
getAbsoluteRect,
getBackColor,
getFont,
getFontMetrics,
getForeColor,
getNext,
getParent,
getParentWindow,
getPos,
getRect,
getSize,
isDisplayed,
isEnabled,
onBoundsChanged,
onWindowPaintFinished,
postEvent,
removeTimer,
repaint,
repaintNow,
requestFocus,
setBackColor,
setBackForeColors,
setFocusLess,
setFont,
setForeColor,
setRect,
setRect,
setRect |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
toString,
wait,
wait |
Field Detail |
public int gap
public static final char CHECKED
public static final char UNCHECKED
public static final char DISABLED
Constructor Detail |
public MenuBar(String[][] items)
Method Detail |
public void setItems(String[][] items)
public void setPopColors(Color back, Color fore, Color cursor)
null
to any parameter to keep the current settings.public void setCursorColor(Color c)
public void setVisible(boolean b)
protected void onFontChanged()
public int getSelectedMenuItem()
public boolean isChecked(int menuItem)
public boolean isCheckable(int menuItem)
public boolean isEnabled(int menuItem)
public void setChecked(int menuItem, boolean check)
Note: the items at the MenuBar cannot be checkable.
public void setEnabled(int menuItem, boolean enable)
protected void onPopup()
protected boolean onClickedOutside(int x, int y)
public void onEvent(Event event)
event
- the event to processEvent
,
KeyEvent
,
PenEvent
protected void postPopup()
protected void popupClosed(PopupMenu pop)
protected void loadBehindLastPopup(int ph)
protected void switchTo(int index)
protected void onColorsChanged(boolean colorsChanged)
public void onPaint(Graphics g)
super.onPaint(g);
, or the border will not be drawn.g
- the graphics object for drawingGraphics
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |