Class IzMenuItem
- Author:
- Christopher Mindus
- Constructor SummaryConstructorsConstructorDescription- IzMenuItem- (IzMenu menu, int style) Constructor.- IzMenuItem- (IzMenu menu, int style, String text) Constructor for menu item.- IzMenuItem- (IzMenu menu, int style, String text, Image image) Constructor for menu item.- IzMenuItem- (IzMenu menu, int style, String text, Image image, Listener selectionListener) Constructor for menu item.- IzMenuItem- (IzMenu menu, int style, String text, Listener selectionListener) Constructor for menu item.- IzMenuItem- (IzMenu menu, IzSubMenu subMenu) Creates a submenu.- IzMenuItem- (IzMenu menu, String text) Constructor for push button menu item.- IzMenuItem- (IzMenu menu, String text, Image image) Constructor for push button menu item.- IzMenuItem- (IzMenu menu, String text, Image image, Listener selectionListener) Constructor for push button menu item.- IzMenuItem- (IzMenu menu, String text, Listener selectionListener) Constructor for push button menu item.- IzMenuItem- (IzMenu menu, IAction action) Creates a menu item from a action.
- Method SummaryModifier and TypeMethodDescription- addListener- (int eventType, Listener listener) Adds the listener to the collection of listeners who will be notified when an event of the given type occurs.- void- dispose()Disposes of the menu item.- void- fireSelectionEvent- (Event event) Fires a selection event to all listeners.- static final IzMenuItemGets the IzMenuItem from a menu event, typically a selection event.- booleanReturns- trueif the receiver is enabled, and- falseotherwise.- getImage()Returns the receiver's image if it has one, or null if it does not.- booleanReturns- trueif the receiver is selected, and false otherwise.Returns the SWT menu item for this menu item.- getText()Returns the receiver's text, which will be an empty string if it has never been set.Gets the tooltip text for the menu item.- booleanVerifies if there are selection listeners for the menu item.- booleanReturns if the menu item is disposed.- booleanThe enabled state is reflected from this menu item state and all parent states.- booleanReturns if this is a separator.- setAccelerator- (int accelerator) Sets the accelerator for plain menu items (not cascaded or contribution items).- setEnabled- (boolean enabled) Enables the receiver if the argument is- true, and disables it otherwise.Sets the receiver's image to the argument, which may be null indicating that no image should be displayed.Sets the menu for the cascaded menu item.- setSelection- (boolean selected) Sets the selection state of the receiver.Sets the receiver's text.- setToolTipText- (String toolTip) Sets the tooltip text for the menu item.
- Constructor Details- IzMenuItemConstructor.- NOTE: supported styles: SWT.SEPARATOR, SWT.PUSH, SWT.CHECK, SWT.RADIO and SWT.CASCADE: NO OTHER! - Parameters:
- menu- The parent menu.
- style- The menu item style.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- IzMenuItemConstructor for push button menu item.- Parameters:
- menu- The parent menu.
- text- The text, null for none.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- IzMenuItemConstructor for push button menu item.- Parameters:
- menu- The parent menu.
- text- The text, null for none.
- selectionListener- The selection listener, or null for none.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- IzMenuItemConstructor for push button menu item.- Parameters:
- menu- The parent menu.
- text- The text, null for none.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- IzMenuItemConstructor for push button menu item.- Parameters:
- menu- The parent menu.
- text- The text, null for none.
- image- The image, null for none.
- selectionListener- The selection listener, or null for none.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- IzMenuItemConstructor for menu item.- NOTE: supported styles: SWT.SEPARATOR, SWT.PUSH, SWT.CHECK, SWT.RADIO and SWT.CASCADE: NO OTHER! - Parameters:
- menu- The parent menu.
- style- The menu item style.
- text- The text, null for none.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- IzMenuItemConstructor for menu item.- NOTE: supported styles: SWT.SEPARATOR, SWT.PUSH, SWT.CHECK, SWT.RADIO and SWT.CASCADE: NO OTHER! - Parameters:
- menu- The parent menu.
- style- The menu item style.
- text- The text, null for none.
- selectionListener- The selection listener, or null for none.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- IzMenuItemConstructor for menu item.- NOTE: supported styles: SWT.SEPARATOR, SWT.PUSH, SWT.CHECK, SWT.RADIO and SWT.CASCADE: NO OTHER! - Parameters:
- menu- The parent menu.
- style- The menu item style.
- text- The text, null for none.
- image- The image, null for none.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- IzMenuItemConstructor for menu item.- NOTE: supported styles: SWT.SEPARATOR, SWT.PUSH, SWT.CHECK, SWT.RADIO and SWT.CASCADE: NO OTHER! - Parameters:
- menu- The parent menu.
- style- The menu item style.
- text- The text, null for none.
- image- The image, null for none.
- selectionListener- The selection listener, or null for none.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- IzMenuItemCreates a menu item from a action.- Parameters:
- menu- The parent menu.
- action- The action.
- Throws:
- NullPointerException- If action is null.
 
- IzMenuItemCreates a submenu.- Parameters:
- menu- The parent menu.
- subMenu- The submenu.
- Throws:
- NullPointerException- If action is null.
 
 
- Method Details- fromEventGets the IzMenuItem from a menu event, typically a selection event.- Parameters:
- event- The event.
- Returns:
- The menu item that corresponds to the event, null if not found.
 
- isSeparatorpublic boolean isSeparator()Returns if this is a separator.
- setMenuSets the menu for the cascaded menu item.- Returns:
- thismenu item to enable concatenation.
- Throws:
- IllegalArgumentException- If action or submenu is used, or if a second call to setMenu(menu) is done.
 
- disposepublic void dispose()Disposes of the menu item.
- isDisposedpublic boolean isDisposed()Returns if the menu item is disposed.- Returns:
- true if disposed, false otherwise.
 
- setEnabledEnables the receiver if the argument is- true, and disables it otherwise. A disabled menu item is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Parameters:
- enabled- the new enabled state
- Returns:
- thismenu item to enable concatenation.
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
- IllegalArgumentException- If action or submenu is used.
 
- getEnabledpublic boolean getEnabled()Returns- trueif the receiver is enabled, and- falseotherwise. A disabled menu item is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Returns:
- the receiver's enabled state.
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
- See Also:
 
- isEnabledpublic boolean isEnabled()The enabled state is reflected from this menu item state and all parent states.- Returns:
- The enabled state of this menu item within the menu, i.e. if a parent is disabled, then false is returned.
 
- setSelectionSets the selection state of the receiver.- When the receiver is of type - CHECKor- RADIO, it is selected when it is checked.- Parameters:
- selected- the new selection state
- Returns:
- thismenu item to enable concatenation.
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
- IllegalArgumentException- If action or submenu is used.
 
- getSelectionpublic boolean getSelection()Returns- trueif the receiver is selected, and false otherwise.- When the receiver is of type - CHECKor- RADIO, it is selected when it is checked.- Returns:
- the selection state
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- setImageSets the receiver's image to the argument, which may be null indicating that no image should be displayed.- Parameters:
- image- the image to display on the receiver (may be null)
- Returns:
- thismenu item to enable concatenation.
- Throws:
- IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the image has been disposed
 
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
- IllegalArgumentException- If action or submenu is used.
 
- getImageReturns the receiver's image if it has one, or null if it does not.- Returns:
- the receiver's image
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- setTextSets the receiver's text.- Note: If control characters like '\n', '\t' etc. are used in the string, then the behavior is platform dependent. - Parameters:
- string- the new text
- Returns:
- thismenu item to enable concatenation.
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the text is null
 
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
- IllegalArgumentException- If action or submenu is used.
 
- getTextReturns the receiver's text, which will be an empty string if it has never been set.- Returns:
- the receiver's text
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- setToolTipTextSets the tooltip text for the menu item.- Parameters:
- toolTip- The tooltip, or null to clear it.
- Returns:
- thismenu item to enable concatenation.
 
- getToolTipTextGets the tooltip text for the menu item.- Returns:
- The tooltip, or null for none.
 
- setAcceleratorSets the accelerator for plain menu items (not cascaded or contribution items). This method will not affect any keyboard processing, merely the display of the accelerator text. It will not change the text if the menu item is visible.- Parameters:
- accelerator- The SWT accelerator or SWT.NONE to clear.
- Returns:
- thismenu item to enable concatenation.
 
- addListenerAdds the listener to the collection of listeners who will be notified when an event of the given type occurs. When the event does occur in the widget, the listener is notified by sending it the- handleEvent()message. The event type is one of the event constants defined in class- SWT.- NOTE: Only SWT.Selection is supported. - Parameters:
- eventType- the type of event to listen for
- listener- the listener which should be notified when the event occurs
- Returns:
- thismenu item to enable concatenation.
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
- IllegalArgumentException- if- listener == nullor- eventType != SWT.Selection.
 
- hasSelectionListenerspublic boolean hasSelectionListeners()Verifies if there are selection listeners for the menu item.- Returns:
- true if listeners are present.
 
- fireSelectionEventFires a selection event to all listeners.- Parameters:
- event- The SWT event.
 
- getSWTMenuItemReturns the SWT menu item for this menu item.- Returns:
- The SWT menu item, only set when processing the menu (it is displayed), otherwise this value is null.