org.gnu.gtk
Class MenuItem

java.lang.Object
  extended by org.gnu.glib.Struct
      extended by org.gnu.glib.GObject
          extended by org.gnu.gtk.GtkObject
              extended by org.gnu.gtk.Widget
                  extended by org.gnu.gtk.Container
                      extended by org.gnu.gtk.Bin
                          extended by org.gnu.gtk.Item
                              extended by org.gnu.gtk.MenuItem
Direct Known Subclasses:
CheckMenuItem, ImageMenuItem, SeparatorMenuItem, TearoffMenuItem

public class MenuItem
extends Item

The MenuItem widget and derived widgets are the only valid children for Menus. Their function is to correctly handle highlighting, alignment, events, and submenus.


Constructor Summary
MenuItem()
          Construct a new menu item.
MenuItem(org.gnu.glib.Handle handle)
          Create a new MenuItem with a handle to a native resource returned from a call to the native libraries.
MenuItem(java.lang.String label, boolean hasMnemonic)
          Construct a new menu item with the provided label.
 
Method Summary
 void addListener(MenuItemListener listener)
          Register an object to receive event notification.
 void emitActivate()
          Emits the "activate" signal on this MenuItem.
 void emitDeselect()
          Emits the "deselect" signal on this MenuItem.
 java.lang.Class getEventListenerClass(java.lang.String signal)
           
 EventType getEventType(java.lang.String signal)
           
static MenuItem getMenuItem(org.gnu.glib.Handle handle)
          Create a new MenuItem with a handle to a native resource returned from a call to the native libraries.
static Type getType()
          Retrieve the runtime type used by the GLib library.
 void removeListener(MenuItemListener listener)
          Unregister an object that was receiving menuitem event notification.
 void removeSubmenu()
          Removes the widget's submenu.
 void setLeftJustified()
          MenuItem's are left justified by default.
 void setRightJustified()
          Sets whether the menu item appears to the right side of the menu bar.
 void setSubmenu(Menu submenu)
          Sets the submenu, or changes it.
 
Methods inherited from class org.gnu.gtk.Item
addListener, deselect, removeListener, select, toggle
 
Methods inherited from class org.gnu.gtk.Bin
getChild
 
Methods inherited from class org.gnu.gtk.Container
add, addListener, getBooleanChildProperty, getBorderWidth, getChildProperty, getChildren, getIntChildProperty, getResizeMode, remove, removeListener, resizeChildren, setBooleanChildProperty, setBorderWidth, setChildProperty, setIntChildProperty, setResizeMode
 
Methods inherited from class org.gnu.gtk.Widget
activate, addAccelerator, addEvents, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, canActivateAccel, createContext, createLayout, draw, drawArea, drawArea, finish, getAccessible, getAllocation, getCanFocus, getColormap, getContext, getData, getDisplay, getDragData, getExtensionEvents, getModifierStyle, getName, getParent, getParentWindow, getPointer, getRootWindow, getScreen, getSensitive, getStyle, getToplevel, getWidget, getWindow, grabDefault, grabFocus, hasFocus, hasScreen, hide, hideAll, highlight, highlight, intersect, isAncestor, makeWidget, modifyStyle, popColormap, pushColormap, realize, removeAccelerator, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, reparent, setBackgroundColor, setBaseColor, setCanFocus, setColormap, setDoubleBuffered, setDragDestination, setDragIcon, setDragIconPixbuf, setDragIconStock, setDragSource, setEvents, setExtensionEvents, setFont, setForegroundColor, setMinimumSize, setName, setNoDragDestination, setNoDragSource, setSensitive, setTextColor, shapeCombineMask, show, showAll, unHighlight, unHighlight
 
Methods inherited from class org.gnu.gtk.GtkObject
destroy, sink
 
Methods inherited from class org.gnu.glib.GObject
addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addListener, collect, freezeNotify, getBooleanProperty, getData, getDoubleProperty, getFloatProperty, getGObjectFromHandle, getIntProperty, getJavaObjectProperty, getLongProperty, getPixbufProperty, getProperty, getStringProperty, hasProperty, notify, removeEventHandler, removeListener, setBooleanProperty, setData, setDoubleProperty, setFloatProperty, setIntProperty, setJavaObjectProperty, setLongProperty, setPixbufProperty, setProperty, setStringProperty, thawNotify
 
Methods inherited from class org.gnu.glib.Struct
equals, getHandle, getNullHandle, hashCode
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuItem

public MenuItem()
Construct a new menu item.


MenuItem

public MenuItem(org.gnu.glib.Handle handle)
Create a new MenuItem with a handle to a native resource returned from a call to the native libraries. Should only be used internally by Java-Gnome.

Parameters:
handle - The handle that represents a pointer to a native resource.

MenuItem

public MenuItem(java.lang.String label,
                boolean hasMnemonic)
Construct a new menu item with the provided label.

Parameters:
label - The label to display in the menu item.
hasMnemonic - Indicates if the provided string contains mnemonics
Method Detail

getMenuItem

public static MenuItem getMenuItem(org.gnu.glib.Handle handle)
Create a new MenuItem with a handle to a native resource returned from a call to the native libraries. Should only be used internally by Java-Gnome.

Parameters:
handle - The handle that represents a pointer to a native resource.

setRightJustified

public void setRightJustified()
Sets whether the menu item appears to the right side of the menu bar. This was traditionally done for the Help menu, but is now considered a bad idea. (If the widget layout is reversed for a right to left language like Hebrew or Arabic, right-justified menu items appear at the left).


setLeftJustified

public void setLeftJustified()
MenuItem's are left justified by default. Use this method to change a MenuItem from right justified back to left justified.


setSubmenu

public void setSubmenu(Menu submenu)
Sets the submenu, or changes it.

Parameters:
submenu - The submenu.

removeSubmenu

public void removeSubmenu()
Removes the widget's submenu.


emitDeselect

public void emitDeselect()
Emits the "deselect" signal on this MenuItem.


emitActivate

public void emitActivate()
Emits the "activate" signal on this MenuItem.


getEventListenerClass

public java.lang.Class getEventListenerClass(java.lang.String signal)
Overrides:
getEventListenerClass in class Item

getEventType

public EventType getEventType(java.lang.String signal)
Overrides:
getEventType in class Item

addListener

public void addListener(MenuItemListener listener)
Register an object to receive event notification.

Parameters:
listener - The object that has implemented the MenuItemListener interface that is to receive the menu item events.

removeListener

public void removeListener(MenuItemListener listener)
Unregister an object that was receiving menuitem event notification.

Parameters:
listener - The object that is to no longer receive menuitem events.

getType

public static Type getType()
Retrieve the runtime type used by the GLib library.