public class MenuBar extends Container implements ActionListener
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR
Constructor and Description |
---|
MenuBar()
Empty Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent evt)
Invoked when a softbutton is pressed
|
void |
addCommand(Command cmd)
Adds a Command to the MenuBar
|
protected void |
addCommand(Command cmd,
int index)
Add a Command to the MenuBar
|
protected Dimension |
calcPreferredSize()
Prevents scaling down of the menu when there is no text on the menu bar
|
protected int |
calculateTouchCommandGridColumns(Container grid)
Calculates the amount of columns to give to the touch commands within the
grid
|
protected Button |
createBackCommandButton() |
protected Component |
createCommandComponent(Vector commands)
Creates the component containing the commands within the given vector
used for showing the menu dialog, this method calls the createCommandList
method by default however it allows more elaborate menu creation.
|
protected List |
createCommandList(Vector commands)
Creates the list component containing the commands within the given vector
used for showing the menu dialog
|
protected Command |
createMenuCancelCommand()
Factory method that returns the Form Menu cancel Command.
|
protected Command |
createMenuSelectCommand()
Factory method that returns the Form Menu select Command.
|
protected Command |
createSelectCommand()
Factory method that returns the Form select Command.
|
protected Button |
createSoftButton(String uiid)
Creates a soft button Component
|
protected Button |
createTouchCommandButton(Command c)
Creates a touch command for use as a touch menu item
|
Button |
findCommandComponent(Command c)
Find the command component instance if such an instance exists
|
Command |
getBackCommand()
Indicates the command that is defined as the back command out of this form.
|
protected Command |
getCancelMenuItem()
This method returns the cancel menu item, when a menu is opened
|
Command |
getClearCommand()
Indicates the command that is defined as the clear command in this form.
|
Command |
getCommand(int index)
Returns the command occupying the given index
|
int |
getCommandBehavior() |
int |
getCommandCount()
Returns number of commands
|
protected Vector |
getCommands()
This method returns a Vector of Command objects
|
Command |
getDefaultCommand()
Default command is invoked when a user presses fire, this functionality works
well in some situations but might collide with elements such as navigation
and combo boxes.
|
protected int |
getDragRegionStatus(int x,
int y)
Indicates if the section within the X/Y area is a "drag region" where
we expect people to drag or press in which case we
can instantly start dragging making perceived performance faster.
|
Style |
getMenuStyle()
Returns the Menu Dialog Style
|
Command |
getSelectCommand()
The selectCommand is the command to invoke when a Component has foucs in
Third Soft Button state.
|
protected Command |
getSelectMenuItem()
This method returns the select menu item, when a menu is opened
|
protected Container |
getTitleAreaContainer()
Returns the parent Form title area
|
protected Component |
getTitleComponent()
Gets the Form titleComponent
|
boolean |
handlesKeycode(int keyCode)
This method returns true if the MenuBar should handle the given keycode.
|
protected void |
initMenuBar(Form parent)
Initialize the MenuBar
|
protected void |
installMenuBar()
Adds the MenuBar on the parent Form
|
boolean |
isMenuShowing()
This method will return true if the menu dialog is currently displaying
|
boolean |
isMinimizeOnBack()
When set to true the physical back button will minimize the application
|
protected boolean |
isReverseSoftButtons()
Allows an individual form to reverse the layout direction of the softbuttons, this method is RTL
sensitive and might reverse the result based on RTL state
|
void |
keyPressed(int keyCode)
If this Component is focused, the key pressed event
will call this method
|
void |
keyReleased(int keyCode)
If this Component is focused, the key released event
will call this method
|
void |
refreshTheme(boolean merge)
Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!
|
protected void |
removeAllCommands()
Remove all commands from the menuBar
|
protected void |
removeCommand(Command cmd)
Removes a Command from the MenuBar
|
void |
removeEmptySoftbuttons()
This method removes empty J2ME softbuttons that don't have a command
|
void |
setBackCommand(Command backCommand)
Indicates the command that is defined as the back command out of this form.
|
void |
setClearCommand(Command clearCommand)
Indicates the command that is defined as the clear command in this form.
|
void |
setCommandUIID(Command cmd,
String uiid)
Sets the command UIID to the given UIID, notice that this won't work for all menu types since some menu
types might be implemented natively or as a list in which case the UIID won't apply!
|
void |
setDefaultCommand(Command defaultCommand)
Default command is invoked when a user presses fire, this functionality works
well in some situations but might collide with elements such as navigation
and combo boxes.
|
void |
setMenuCellRenderer(ListCellRenderer menuCellRenderer)
The MenuBar default implementation shows the menu commands in a List
contained in a Dialog.
|
void |
setMinimizeOnBack(boolean minimizeOnBack)
When set to true the physical back button will minimize the application
|
void |
setSelectCommand(Command selectCommand)
Sets the select command
|
void |
setTransitions(Transition transitionIn,
Transition transitionOut)
Sets the menu transitions for showing/hiding the menu, can be null...
|
void |
setUnselectedStyle(Style style)
Changes the Component Style by replacing the Component Style with the given Style
|
void |
showMenu()
This method shows the menu on the Form.
|
protected Command |
showMenuDialog(Dialog menu)
A menu is implemented as a dialog, this method allows you to override dialog
display in order to customize the dialog menu in various ways
|
protected void |
unInstallMenuBar()
Removes the MenuBar from the parent Form
|
add, add, add, add, add, add, addAll, addComponent, addComponent, addComponent, addComponent, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints, clearClientProperties, constrainHeightWhenScrollable, constrainWidthWhenScrollable, contains, createAnimateHierarchy, createAnimateHierarchyFade, createAnimateLayout, createAnimateLayoutFade, createAnimateLayoutFadeAndWait, createAnimateMotion, createAnimateUnlayout, createReplaceTransition, dragInitiated, drop, encloseIn, encloseIn, findDropTargetAt, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getChildrenAsList, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getResponderAt, getSafeAreaRoot, getScrollIncrement, getSideGap, getUIManager, initLaf, invalidate, isEnabled, isSafeArea, isSafeAreaRoot, isScrollableX, isScrollableY, isSelectableInteraction, isSurface, iterator, iterator, layoutContainer, morph, morphAndWait, paint, paintBackground, paintBorderBackground, paintComponentBackground, paintGlass, paramString, pointerPressed, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, revalidateLater, revalidateWithAnimationSafety, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setSafeArea, setSafeAreaRoot, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout, setUIManager, updateTabIndices
addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, animate, bindProperty, blocksSideSwipe, calcScrollSize, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragSpeed, getDragTransparency, getEditingDelegate, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getUIID, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setPropertyValue, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContains
protected void initMenuBar(Form parent)
parent
- the associated Formpublic void removeEmptySoftbuttons()
public int getCommandBehavior()
public void setDefaultCommand(Command defaultCommand)
defaultCommand
- the command to treat as defaultpublic Command getDefaultCommand()
public void setClearCommand(Command clearCommand)
clearCommand
- the command to treat as the clear Commandpublic Command getClearCommand()
public Button findCommandComponent(Command c)
c
- the command instancepublic void setBackCommand(Command backCommand)
backCommand
- the command to treat as the back Commandpublic Command getBackCommand()
public Command getSelectCommand()
public void setSelectCommand(Command selectCommand)
selectCommand
- public void actionPerformed(ActionEvent evt)
actionPerformed
in interface ActionListener
evt
- event object describing the source of the action as well as
its triggerprotected Button createSoftButton(String uiid)
public void setUnselectedStyle(Style style)
setUnselectedStyle
in class Component
style
- the component Style objectprotected Dimension calcPreferredSize()
calcPreferredSize
in class Container
public void setTransitions(Transition transitionIn, Transition transitionOut)
public boolean isMenuShowing()
public void showMenu()
protected Button createBackCommandButton()
public void addCommand(Command cmd)
cmd
- Command to addpublic Command getCommand(int index)
index
- offset of the commandpublic int getCommandCount()
protected void addCommand(Command cmd, int index)
cmd
- Command to Addindex
- determines the order of the added commandsprotected void installMenuBar()
protected void unInstallMenuBar()
protected void removeAllCommands()
protected void removeCommand(Command cmd)
cmd
- Command to removeprotected Command createSelectCommand()
protected Command createMenuSelectCommand()
protected Command createMenuCancelCommand()
public void setMenuCellRenderer(ListCellRenderer menuCellRenderer)
menuCellRenderer
- public Style getMenuStyle()
public boolean handlesKeycode(int keyCode)
keyCode
- to determine if the MenuBar is responsible for.public void keyPressed(int keyCode)
keyPressed
in class Container
keyCode
- the key code value to indicate a physical key.public void keyReleased(int keyCode)
keyReleased
in class Container
keyCode
- the key code value to indicate a physical key.public void refreshTheme(boolean merge)
refreshTheme
in class Container
merge
- indicates if the current styles should be merged with the new stylesprotected Command showMenuDialog(Dialog menu)
menu
- a dialog containing menu options that can be customizedprotected boolean isReverseSoftButtons()
protected int calculateTouchCommandGridColumns(Container grid)
grid
- container that will be arranged in the grid containing the
componentspublic void setCommandUIID(Command cmd, String uiid)
cmd
- the commanduiid
- the uiid for the given commandprotected Button createTouchCommandButton(Command c)
c
- command to map into the returned buttonprotected Component createCommandComponent(Vector commands)
commands
- list of command objectsprotected Vector getCommands()
protected List createCommandList(Vector commands)
commands
- list of command objectsprotected Command getSelectMenuItem()
protected Command getCancelMenuItem()
public boolean isMinimizeOnBack()
public void setMinimizeOnBack(boolean minimizeOnBack)
minimizeOnBack
- the minimizeOnBack to setprotected int getDragRegionStatus(int x, int y)
getDragRegionStatus
in class Component
x
- x location for the touchy
- y location for the touchprotected Container getTitleAreaContainer()
protected Component getTitleComponent()