java-gnome version 4.0.19

org.gnome.gtk
Class Menu

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.MenuShell
                              extended by org.gnome.gtk.Menu
Direct Known Subclasses:
RecentChooserMenu

public class Menu
extends MenuShell

A drop-down set of Widgets creating a menu. Menus consist of other MenuItems. Menus are either placed inside a MenuBar or another MenuItem, thereby forming a sub-menu. An entire hierarchy of Menu structures can thus be created by appropriately placing Menus inside MenuBars or MenuItems.

A "context menu" (a stand-alone menu which pops-up) can also be created; this is commonly used to create a context sensitive popup menu in response to a right-click (or left-click as the case may be); see the popup() method.

For a broader explanation of the Menu API see MenuShell.

GTK does have the ability to "tear" Menus off from the parent Container. After consistently poor results in usability testing, however, tear-off menus are now highly discouraged in the GNOME community. They are therefore not presented in the java-gnome bindings.

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

Nested Class Summary
 
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
Menu()
          Construct a new Menu.
 
Method Summary
 void popup()
          Popup a context menu.
 void popup(int x, int y)
          Having constructed a Menu to be used as the context menu, present it at the specified location.
 void popup(StatusIcon status)
          A special case for popping up the context menu associated with a StatusIcon.
 void setAcceleratorGroup(AcceleratorGroup group)
          This method must be called in order to have the key bindings in MenuItems work.
 
Methods inherited from class org.gnome.gtk.MenuShell
append, deactivate, insert, prepend
 
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

Menu

public Menu()
Construct a new Menu.

Since:
4.0.3
Method Detail

popup

public void popup()
Popup a context menu. Use this when you create a Menu that will be used for the popup context menu in response to a right-click somewhere. The menu will appear where the mouse pointer is.

Unlike normal Menus that are part of an application's MenuBar, context menus are not mapped automatically, so you need to have showAll() called on them once you're done building them to allocate their resources (otherwise you end up with a 1x1 pixel sized menu with nothing in it).

Since:
4.0.3

popup

public void popup(int x,
                  int y)
Having constructed a Menu to be used as the context menu, present it at the specified location. This is useful in conjunction with TextView's getLocation() if you wish to place the menu at the "cursor position" rather than where the mouse pointer is.

Since:
4.0.15

popup

public void popup(StatusIcon status)
A special case for popping up the context menu associated with a StatusIcon. Having constructed a Menu to be used as the context menu, you then call this from the StatusIcon.PopupMenu signal callback as follows:
 StatusIcon si;
 Menu context;
 ...
 
 si.connect(new StatusIcon.PopupMenu() {
     public void onPopupMenu(StatusIcon source, int button, int activateTime) {
         context.popup(source);
     }
 });
 
Don't forget to call showAll() on the Menu when you're done constructing it before trying to use it the first time.

Since:
4.0.3

setAcceleratorGroup

public void setAcceleratorGroup(AcceleratorGroup group)
This method must be called in order to have the key bindings in MenuItems work. It has to be the same AcceleratorGroup that was specified for the enclosing top level Window that this Menu will be a part of via Window's addAcceleratorGroup().

Since:
4.0.16


java-gnome