public class Menu extends Widget
Note: Only one of BAR, DROP_DOWN and POP_UP may be specified. Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
IMPORTANT: This class is not intended to be subclassed.
| Modifier and Type | Field and Description | 
|---|---|
| (package private) int | background | 
| (package private) Image | backgroundImage | 
| (package private) MenuItem | cascade | 
| (package private) int | foreground | 
| int | handlethe handle to the OS resource 
 (Warning: This field is platform dependent)
 
 IMPORTANT: This field is not part of the SWT
 public API. | 
| (package private) boolean | hasLocation | 
| (package private) int | hBrush | 
| (package private) int | hwndCB | 
| (package private) static int | ID_PPC | 
| (package private) static int | ID_SPBB | 
| (package private) static int | ID_SPBM | 
| (package private) static int | ID_SPMB | 
| (package private) static int | ID_SPMM | 
| (package private) static int | ID_SPSOFTKEY0 | 
| (package private) static int | ID_SPSOFTKEY1 | 
| (package private) int | id0 | 
| (package private) int | id1 | 
| (package private) ImageList | imageList | 
| (package private) Decorations | parent | 
| (package private) int | x | 
| (package private) int | y | 
CANVAS, data, DEFAULT_HEIGHT, DEFAULT_WIDTH, DISABLED, display, DISPOSE_SENT, DISPOSED, DRAG_DETECT, DRAW_BACKGROUND, eventTable, FOREIGN_HANDLE, HIDDEN, IGNORE_WM_CHANGEUISTATE, KEYED_DATA, LAYOUT_CHANGED, LAYOUT_CHILD, LAYOUT_NEEDED, MAJOR, MINOR, MOVE_DEFERRED, MOVE_OCCURRED, PARENT_BACKGROUND, RELEASED, RESIZE_DEFERRED, RESIZE_OCCURRED, SKIN_NEEDED, state, style, THEME_BACKGROUND, TRACK_MOUSE| Constructor and Description | 
|---|
| Menu(Control parent)Constructs a new instance of this class given its parent,
 and sets the style for the instance so that the instance
 will be a popup menu on the given parent's shell. | 
| Menu(Decorations parent,
    int style)Constructs a new instance of this class given its parent
 (which must be a  Decorations) and a style value
 describing its behavior and appearance. | 
| Menu(Decorations parent,
    int style,
    int handle) | 
| Menu(Menu parentMenu)Constructs a new instance of this class given its parent
 (which must be a  Menu) and sets the style
 for the instance so that the instance will be a drop-down
 menu on the given parent's parent. | 
| Menu(MenuItem parentItem)Constructs a new instance of this class given its parent
 (which must be a  MenuItem) and sets the style
 for the instance so that the instance will be a drop-down
 menu on the given parent's parent menu. | 
| Modifier and Type | Method and Description | 
|---|---|
| (package private) void | _setOrientation(int orientation) | 
| (package private) void | _setVisible(boolean visible) | 
| void | addHelpListener(HelpListener listener)Adds the listener to the collection of listeners who will
 be notified when help events are generated for the control,
 by sending it one of the messages defined in the
  HelpListenerinterface. | 
| void | addMenuListener(MenuListener listener)Adds the listener to the collection of listeners who will
 be notified when menus are hidden or shown, by sending it
 one of the messages defined in the  MenuListenerinterface. | 
| (package private) static Control | checkNull(Control control) | 
| (package private) static Menu | checkNull(Menu menu) | 
| (package private) static MenuItem | checkNull(MenuItem item) | 
| (package private) static int | checkStyle(int style) | 
| (package private) void | createHandle() | 
| (package private) void | createItem(MenuItem item,
          int index) | 
| (package private) void | createWidget() | 
| (package private) int | defaultBackground() | 
| (package private) int | defaultForeground() | 
| (package private) void | destroyAccelerators() | 
| (package private) void | destroyItem(MenuItem item) | 
| (package private) void | destroyWidget()Destroys the widget in the operating system and releases
 the widget's handle. | 
| (package private) void | fixMenus(Decorations newParent) | 
| (package private) Color | getBackground()Returns the receiver's background color. | 
| (package private) Image | getBackgroundImage()Returns the receiver's background image. | 
| (package private) Rectangle | getBounds()Returns a rectangle describing the receiver's size and location
 relative to its parent (or its display if its parent is null),
 unless the receiver is a menu or a shell. | 
| MenuItem | getDefaultItem()Returns the default menu item or null if none has
 been previously set. | 
| boolean | getEnabled()Returns  trueif the receiver is enabled, andfalseotherwise. | 
| (package private) Color | getForeground()Returns the foreground color that the receiver will use to draw. | 
| MenuItem | getItem(int index)Returns the item at the given, zero-relative index in the
 receiver. | 
| int | getItemCount()Returns the number of items contained in the receiver. | 
| MenuItem[] | getItems()Returns a (possibly empty) array of  MenuItems which
 are the items in the receiver. | 
| (package private) int | GetMenuItemCount(int handle) | 
| (package private) java.lang.String | getNameText() | 
| int | getOrientation()Returns the orientation of the receiver, which will be one of the
 constants  SWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT. | 
| Decorations | getParent()Returns the receiver's parent, which must be a  Decorations. | 
| MenuItem | getParentItem()Returns the receiver's parent item, which must be a
  MenuItemor null when the receiver is a
 root. | 
| Menu | getParentMenu()Returns the receiver's parent item, which must be a
  Menuor null when the receiver is a
 root. | 
| Shell | getShell()Returns the receiver's shell. | 
| boolean | getVisible()Returns  trueif the receiver is visible, andfalseotherwise. | 
| (package private) int | imageIndex(Image image) | 
| int | indexOf(MenuItem item)Searches the receiver's list starting at the first item
 (index 0) until an item is found that is equal to the 
 argument, and returns the index of that item. | 
| boolean | isEnabled()Returns  trueif the receiver is enabled and all
 of the receiver's ancestors are enabled, andfalseotherwise. | 
| boolean | isVisible()Returns  trueif the receiver is visible and all
 of the receiver's ancestors are visible andfalseotherwise. | 
| (package private) void | redraw() | 
| (package private) void | releaseChildren(boolean destroy) | 
| (package private) void | releaseHandle() | 
| (package private) void | releaseParent() | 
| (package private) void | releaseWidget() | 
| void | removeHelpListener(HelpListener listener)Removes the listener from the collection of listeners who will
 be notified when the help events are generated for the control. | 
| void | removeMenuListener(MenuListener listener)Removes the listener from the collection of listeners who will
 be notified when the menu events are generated for the control. | 
| (package private) void | reskinChildren(int flags) | 
| (package private) void | setBackground(Color color)Sets the receiver's background color to the color specified
 by the argument, or to the default system color for the control
 if the argument is null. | 
| (package private) void | setBackgroundImage(Image image)Sets the receiver's background image to the image specified
 by the argument, or to the default system color for the control
 if the argument is null. | 
| void | setDefaultItem(MenuItem item)Sets the default menu item to the argument or removes
 the default emphasis when the argument is  null. | 
| void | setEnabled(boolean enabled)Enables the receiver if the argument is  true,
 and disables it otherwise. | 
| (package private) void | setForeground(Color color)Sets the receiver's foreground color to the color specified
 by the argument, or to the default system color for the control
 if the argument is null. | 
| void | setLocation(int x,
           int y)Sets the location of the receiver, which must be a popup,
 to the point specified by the arguments which are relative
 to the display. | 
| void | setLocation(Point location)Sets the location of the receiver, which must be a popup,
 to the point specified by the argument which is relative
 to the display. | 
| void | setOrientation(int orientation)Sets the orientation of the receiver, which must be one
 of the constants  SWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT. | 
| void | setVisible(boolean visible)Marks the receiver as visible if the argument is  true,
 and marks it invisible otherwise. | 
| (package private) void | update() | 
| (package private) void | updateBackground() | 
| (package private) void | updateForeground() | 
_addListener, addDisposeListener, addListener, callWindowProc, checkBits, checkOpened, checkOrientation, checkParent, checkSubclass, checkWidget, DeferWindowPos, dispose, dragDetect, error, filters, findItem, fixMnemonic, fixMnemonic, getData, getData, getDisplay, getListeners, getMenu, getName, getStyle, hooks, isDisposed, isListening, isValidSubclass, isValidThread, mapEvent, new_GC, notifyListeners, postEvent, postEvent, release, removeDisposeListener, removeListener, removeListener, reskin, reskinWidget, sendDragEvent, sendDragEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendFocusEvent, sendKeyEvent, sendKeyEvent, sendMouseEvent, sendMouseEvent, sendMouseWheelEvent, sendSelectionEvent, sendSelectionEvent, setData, setData, setInputState, setKeyState, setLocationMask, setTabGroupFocus, setTabItemFocus, SetWindowPos, showMenu, showMenu, toString, updateMenuLocation, wmCaptureChanged, wmChar, wmContextMenu, wmIMEChar, wmKeyDown, wmKeyUp, wmKillFocus, wmLButtonDblClk, wmLButtonDown, wmLButtonUp, wmMButtonDblClk, wmMButtonDown, wmMButtonUp, wmMouseHover, wmMouseHWheel, wmMouseLeave, wmMouseMove, wmMouseWheel, wmNCPaint, wmPaint, wmPrint, wmRButtonDblClk, wmRButtonDown, wmRButtonUp, wmSetFocus, wmSysChar, wmSysKeyDown, wmSysKeyUp, wmXButtonDblClk, wmXButtonDown, wmXButtonUppublic int handle
IMPORTANT: This field is not part of the SWT public API. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms and should never be accessed from application code.
int x
int y
int hBrush
int hwndCB
int id0
int id1
int foreground
int background
Image backgroundImage
boolean hasLocation
MenuItem cascade
Decorations parent
ImageList imageList
static final int ID_PPC
static final int ID_SPMM
static final int ID_SPBM
static final int ID_SPMB
static final int ID_SPBB
static final int ID_SPSOFTKEY0
static final int ID_SPSOFTKEY1
public Menu(Control parent)
 After constructing a menu, it can be set into its parent
 using parent.setMenu(menu).  In this case, the parent may
 be any control in the same widget tree as the parent.
 
parent - a control which will be the parent of the new instance (cannot be null)java.lang.IllegalArgumentException - SWTException - SWT.POP_UP, 
Widget.checkSubclass(), 
Widget.getStyle()public Menu(Decorations parent, int style)
Decorations) and a style value
 describing its behavior and appearance.
 
 The style value is either one of the style constants defined in
 class SWT which is applicable to instances of this
 class, or must be built by bitwise OR'ing together 
 (that is, using the int "|" operator) two or more
 of those SWT style constants. The class description
 lists the style constants that are applicable to the class.
 Style bits are also inherited from superclasses.
 
 After constructing a menu or menuBar, it can be set into its parent
 using parent.setMenu(menu) or parent.setMenuBar(menuBar).
 
parent - a decorations control which will be the parent of the new instance (cannot be null)style - the style of menu to constructjava.lang.IllegalArgumentException - SWTException - SWT.BAR, 
SWT.DROP_DOWN, 
SWT.POP_UP, 
SWT.NO_RADIO_GROUP, 
SWT.LEFT_TO_RIGHT, 
SWT.RIGHT_TO_LEFT, 
Widget.checkSubclass(), 
Widget.getStyle()public Menu(Menu parentMenu)
Menu) and sets the style
 for the instance so that the instance will be a drop-down
 menu on the given parent's parent.
 
 After constructing a drop-down menu, it can be set into its parentMenu
 using parentMenu.setMenu(menu).
 
parentMenu - a menu which will be the parent of the new instance (cannot be null)java.lang.IllegalArgumentException - SWTException - SWT.DROP_DOWN, 
Widget.checkSubclass(), 
Widget.getStyle()public Menu(MenuItem parentItem)
MenuItem) and sets the style
 for the instance so that the instance will be a drop-down
 menu on the given parent's parent menu.
 
 After constructing a drop-down menu, it can be set into its parentItem
 using parentItem.setMenu(menu).
 
parentItem - a menu item which will be the parent of the new instance (cannot be null)java.lang.IllegalArgumentException - SWTException - SWT.DROP_DOWN, 
Widget.checkSubclass(), 
Widget.getStyle()Menu(Decorations parent, int style, int handle)
void _setVisible(boolean visible)
public void addHelpListener(HelpListener listener)
HelpListener interface.listener - the listener which should be notifiedjava.lang.IllegalArgumentException - SWTException - HelpListener, 
removeHelpListener(org.eclipse.swt.events.HelpListener)public void addMenuListener(MenuListener listener)
MenuListener
 interface.listener - the listener which should be notifiedjava.lang.IllegalArgumentException - SWTException - MenuListener, 
removeMenuListener(org.eclipse.swt.events.MenuListener)static int checkStyle(int style)
void createHandle()
void createItem(MenuItem item, int index)
void createWidget()
int defaultBackground()
int defaultForeground()
void destroyAccelerators()
void destroyItem(MenuItem item)
void destroyWidget()
Widget
 When a widget is destroyed in the operating system, its
 descendants are also destroyed by the operating system.
 This means that it is only necessary to call destroyWidget
 on the root of the widget tree.
 
 This method is called after releaseWidget().
 
 See also releaseChild(), releaseWidget()
 and releaseHandle().
 
destroyWidget in class WidgetWidget.dispose()void fixMenus(Decorations newParent)
Color getBackground()
SWTException - Image getBackgroundImage()
SWTException - Rectangle getBounds()
Note that the bounds of a menu or menu item are undefined when the menu is not visible. This is because most platforms compute the bounds of a menu dynamically just before it is displayed.
SWTException - public MenuItem getDefaultItem()
SWTException - public boolean getEnabled()
true if the receiver is enabled, and
 false otherwise. A disabled menu is typically
 not selectable from the user interface and draws with an
 inactive or "grayed" look.SWTException - isEnabled()Color getForeground()
SWTException - public MenuItem getItem(int index)
index - the index of the item to returnjava.lang.IllegalArgumentException - SWTException - public int getItemCount()
SWTException - public MenuItem[] getItems()
MenuItems which
 are the items in the receiver. 
 Note: This is not the actual structure used by the receiver to maintain its list of items, so modifying the array will not affect the receiver.
SWTException - int GetMenuItemCount(int handle)
java.lang.String getNameText()
getNameText in class Widgetpublic int getOrientation()
SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.SWTException - public Decorations getParent()
Decorations.SWTException - public MenuItem getParentItem()
MenuItem or null when the receiver is a
 root.SWTException - public Menu getParentMenu()
Menu or null when the receiver is a
 root.SWTException - public Shell getShell()
SWTException - getParent()public boolean getVisible()
true if the receiver is visible, and
 false otherwise.
 If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, this method may still indicate that it is considered visible even though it may not actually be showing.
SWTException - int imageIndex(Image image)
public int indexOf(MenuItem item)
item - the search itemjava.lang.IllegalArgumentException - SWTException - public boolean isEnabled()
true if the receiver is enabled and all
 of the receiver's ancestors are enabled, and false
 otherwise. A disabled menu is typically not selectable from the
 user interface and draws with an inactive or "grayed" look.SWTException - getEnabled()public boolean isVisible()
true if the receiver is visible and all
 of the receiver's ancestors are visible and false
 otherwise.SWTException - getVisible()void redraw()
void releaseHandle()
releaseHandle in class Widgetvoid releaseChildren(boolean destroy)
releaseChildren in class Widgetvoid releaseParent()
releaseParent in class Widgetvoid releaseWidget()
releaseWidget in class Widgetpublic void removeHelpListener(HelpListener listener)
listener - the listener which should no longer be notifiedjava.lang.IllegalArgumentException - SWTException - HelpListener, 
addHelpListener(org.eclipse.swt.events.HelpListener)public void removeMenuListener(MenuListener listener)
listener - the listener which should no longer be notifiedjava.lang.IllegalArgumentException - SWTException - MenuListener, 
addMenuListener(org.eclipse.swt.events.MenuListener)void reskinChildren(int flags)
reskinChildren in class Widgetvoid setBackground(Color color)
color - the new color (or null)java.lang.IllegalArgumentException - SWTException - void setBackgroundImage(Image image)
image - the new image (or null)java.lang.IllegalArgumentException - SWTException - void setForeground(Color color)
color - the new color (or null)java.lang.IllegalArgumentException - SWTException - public void setDefaultItem(MenuItem item)
null.item - the default menu item or nulljava.lang.IllegalArgumentException - SWTException - public void setEnabled(boolean enabled)
true,
 and disables it otherwise. A disabled menu is typically
 not selectable from the user interface and draws with an
 inactive or "grayed" look.enabled - the new enabled stateSWTException - public void setLocation(int x,
               int y)
Note that this is different from most widgets where the location of the widget is relative to the parent.
Note that the platform window manager ultimately has control over the location of popup menus.
x - the new x coordinate for the receivery - the new y coordinate for the receiverSWTException - public void setLocation(Point location)
Note that this is different from most widgets where the location of the widget is relative to the parent.
Note that the platform window manager ultimately has control over the location of popup menus.
location - the new location for the receiverjava.lang.IllegalArgumentException - SWTException - public void setOrientation(int orientation)
SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.
 orientation - new orientation styleSWTException - void _setOrientation(int orientation)
public void setVisible(boolean visible)
true,
 and marks it invisible otherwise. 
 If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, marking it visible may not actually cause it to be displayed.
visible - the new visibility stateSWTException - void update()
void updateBackground()
void updateForeground()