|
Eclipse Rich Ajax Platform | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.swt.widgets.Widget org.eclipse.swt.widgets.Menu
public class Menu
Instances of this class are user interface objects that contain menu items.
Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
IMPORTANT: This class is not intended to be subclassed.
Constructor Summary | |
---|---|
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(Menu menu)
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 parent)
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. |
Method Summary | ||
---|---|---|
void |
addHelpListener(HelpListener listener)
Adds the listener to the collection of listeners who will be notified when the help events are generated for the control, by sending it one of the messages defined in the HelpListener
interface. |
|
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 MenuListener
interface. |
|
|
getAdapter(java.lang.Class<T> adapter)
Implementation of the Adaptable interface. |
|
MenuItem |
getDefaultItem()
Returns the default menu item or null if none has been previously set. |
|
boolean |
getEnabled()
Returns true if the receiver is enabled, and
false otherwise. |
|
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 MenuItem s which
are the items in the receiver. |
|
int |
getOrientation()
Returns the orientation of the receiver, which will be one of the constants SWT.LEFT_TO_RIGHT or SWT.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 MenuItem or null when the receiver is a
root. |
|
Menu |
getParentMenu()
Returns the receiver's parent item, which must be a Menu or null when the receiver is a
root. |
|
Shell |
getShell()
Returns the receiver's shell. |
|
boolean |
getVisible()
Returns true if the receiver is visible, and
false otherwise. |
|
int |
indexOf(MenuItem menuItem)
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 true if the receiver is enabled and all
of the receiver's ancestors are enabled, and false
otherwise. |
|
boolean |
isVisible()
Returns true if the receiver is visible and all
of the receiver's ancestors are visible and false
otherwise. |
|
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. |
|
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. |
|
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_RIGHT or SWT.RIGHT_TO_LEFT . |
|
void |
setVisible(boolean visible)
Marks the receiver as visible if the argument is true ,
and marks it invisible otherwise. |
Methods inherited from class org.eclipse.swt.widgets.Widget |
---|
addDisposeListener, addListener, checkSubclass, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, reskin, setData, setData, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Menu(Menu menu)
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
- 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 parent)
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.
parent
- 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()
public Menu(Control 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.
parent
- a decorations control which will be the parent of the new instance (cannot be null)style
- the style of menu to construct
java.lang.IllegalArgumentException
- SWTException
- SWT.BAR
,
SWT.DROP_DOWN
,
SWT.POP_UP
,
SWT.NO_RADIO_GROUP
,
Widget.checkSubclass()
,
Widget.getStyle()
Method Detail |
---|
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 <T> T getAdapter(java.lang.Class<T> adapter)
Widget
Adaptable
interface.
IMPORTANT: This method is not part of the RWT public API. It is marked public only so that it can be shared within the packages provided by RWT. It should never be accessed from application code.
getAdapter
in interface Adaptable
getAdapter
in class Widget
adapter
- the lookup class
null
if
there is no adapter associated with the given class.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 receiver
SWTException
- 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 receiver
java.lang.IllegalArgumentException
- SWTException
- public Shell getShell()
SWTException
- getParent()
public void setOrientation(int orientation)
SWT.LEFT_TO_RIGHT
or SWT.RIGHT_TO_LEFT
.
Note: Currently RWT does not support SWT.RIGHT_TO_LEFT.
orientation
- new orientation style
SWTException
- public int getOrientation()
SWT.LEFT_TO_RIGHT
or SWT.RIGHT_TO_LEFT
.
Note: Currently RWT does not support SWT.RIGHT_TO_LEFT.
SWTException
- 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 state
SWTException
- 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
- public boolean isVisible()
true
if the receiver is visible and all
of the receiver's ancestors are visible and false
otherwise.
SWTException
- getVisible()
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 state
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()
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 int getItemCount()
SWTException
- public MenuItem[] getItems()
MenuItem
s 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
- public MenuItem getItem(int index)
index
- the index of the item to return
java.lang.IllegalArgumentException
- SWTException
- public int indexOf(MenuItem menuItem)
menuItem
- the search item
java.lang.IllegalArgumentException
- SWTException
- public void setDefaultItem(MenuItem item)
null
.
item
- the default menu item or null
java.lang.IllegalArgumentException
- SWTException
- public MenuItem getDefaultItem()
SWTException
- public void addMenuListener(MenuListener listener)
MenuListener
interface.
listener
- the listener which should be notified
java.lang.IllegalArgumentException
- SWTException
- MenuListener
,
removeMenuListener(org.eclipse.swt.events.MenuListener)
public void removeMenuListener(MenuListener listener)
listener
- the listener which should no longer be notified
java.lang.IllegalArgumentException
- SWTException
- MenuListener
,
addMenuListener(org.eclipse.swt.events.MenuListener)
public void addHelpListener(HelpListener listener)
HelpListener
interface.
listener
- the listener which should be notified
java.lang.IllegalArgumentException
- SWTException
- HelpListener
,
removeHelpListener(org.eclipse.swt.events.HelpListener)
public void removeHelpListener(HelpListener listener)
listener
- the listener which should no longer be notified
java.lang.IllegalArgumentException
- SWTException
- HelpListener
,
addHelpListener(org.eclipse.swt.events.HelpListener)
|
Eclipse Rich Ajax Platform | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (c) EclipseSource and others 2002, 2012. All rights reserved.