java-gnome version 4.0.19

org.gnome.gtk
Class MenuItem

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.freedesktop.bindings.Proxy
          extended by org.gnome.glib.Object
              extended by org.gnome.gtk.Object
                  extended by org.gnome.gtk.Widget
                      extended by org.gnome.gtk.Container
                          extended by org.gnome.gtk.Bin
                              extended by org.gnome.gtk.Item
                                  extended by org.gnome.gtk.MenuItem
All Implemented Interfaces:
Activatable
Direct Known Subclasses:
CheckMenuItem, ImageMenuItem, SeparatorMenuItem, TearoffMenuItem

public class MenuItem
extends Item
implements Activatable

MenuItems are the basic elements that form a Menu. While MenuItems are Containers and are thus capable of containing other Widgets; in practise only the specialized MenuItem classes will work properly as they are what support highlighting, alignment, submenus, etc.

MenuItems can be either left justified or right justified, but in general you should just leave this alone and it will do the right thing for your locale (left aligned for western languages, right aligned for right-to-left languages like Arabic).

Right justification was initially designed to be used for "Help" Menus, but this is now considered a bad idea and is no longer used in GNOME.

Since:
4.0.3
Author:
Sebastian Mancke, Andrew Cowie, Srichand Pendyala, Vreixo Formoso

Nested Class Summary
static interface MenuItem.Activate
          The handler interface for an activation.
 
Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.EnterNotifyEvent, Widget.ExposeEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.ScrollEvent, Widget.UnmapEvent, Widget.VisibilityNotifyEvent
 
Nested classes/interfaces inherited from class org.gnome.gtk.Object
Object.Destroy
 
Constructor Summary
MenuItem()
          Construct a MenuItem
MenuItem(String mnemonicLabel)
          Construct a MenuItem with a given text label.
MenuItem(String mnemonicLabel, MenuItem.Activate handler)
          Construct a MenuItem with a given text label, and additionally connect a handler to its MenuItem.Activate signal.
 
Method Summary
 void connect(MenuItem.Activate handler)
          Connect an MenuItem.Activate handler to the widget.
 Action getRelatedAction()
          Get the Action that is triggered when this Activatable is activated, if any.
 Widget getSubmenu()
          Returns the submenu underneath this menu item, if any
 void setAccelerator(AcceleratorGroup group, Keyval keyval, ModifierType modifier)
          Set a key binding for this MenuItem.
 void setRelatedAction(Action action)
          Set the Action that is triggered when this Activatable is activated.
 void setSubmenu(Menu child)
          Sets or replaces the MenuItem's submenu, or removes it if a null Menu is passed.
 
Methods inherited from class org.gnome.gtk.Bin
getChild
 
Methods inherited from class org.gnome.gtk.Container
add, getChildren, remove, setBorderWidth
 
Methods inherited from class org.gnome.gtk.Widget
activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getRequisition, getSensitive, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, modifyBackground, modifyBase, modifyFont, modifyText, queueDraw, queueDrawArea, realize, setCanDefault, setCanFocus, setColormap, setEvents, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll
 
Methods inherited from class org.gnome.gtk.Object
connect, destroy
 
Methods inherited from class org.freedesktop.bindings.Pointer
toString
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MenuItem

public MenuItem()
Construct a MenuItem

Since:
4.0.3

MenuItem

public MenuItem(String mnemonicLabel)
Construct a MenuItem with a given text label. The label may contain underscores (the _ character) which, if present, will indicate the mnemonic which will activate that MenuItem directly if that key is pressed (whilst the Menu is showing, obviously).

Since:
4.0.3

MenuItem

public MenuItem(String mnemonicLabel,
                MenuItem.Activate handler)
Construct a MenuItem with a given text label, and additionally connect a handler to its MenuItem.Activate signal.

This is equivalent to:

 item = new MenuItem("_My menu item");
 item.connect(handler);
 
and affords you the convenience of being able to add a MenuItem fairly compactly:
 Menu editMenu;
    
 editMenu.append(new MenuItem("_Paste", new MenuItem.Activate() {
     public void onActivate(MenuItem source) {
         ...
     }
 }));
 

Since:
4.0.4
Method Detail

connect

public void connect(MenuItem.Activate handler)
Connect an MenuItem.Activate handler to the widget.

Since:
4.0.3

getRelatedAction

public Action getRelatedAction()
Description copied from interface: Activatable
Get the Action that is triggered when this Activatable is activated, if any.

Specified by:
getRelatedAction in interface Activatable

getSubmenu

public Widget getSubmenu()
Returns the submenu underneath this menu item, if any

Returns:
submenu for this menu item, or null if none.
Since:
4.0.3

setAccelerator

public void setAccelerator(AcceleratorGroup group,
                           Keyval keyval,
                           ModifierType modifier)
Set a key binding for this MenuItem.

Since:
4.0.16

setRelatedAction

public void setRelatedAction(Action action)
Description copied from interface: Activatable
Set the Action that is triggered when this Activatable is activated.

This replaced Action's connectProxy().

Specified by:
setRelatedAction in interface Activatable

setSubmenu

public void setSubmenu(Menu child)
Sets or replaces the MenuItem's submenu, or removes it if a null Menu is passed.

Since:
4.0.3


java-gnome