public class Menu extends MenuShell
MenuItem
s. 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.
Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.Destroy, Widget.Draw, Widget.EnterNotifyEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.QueryTooltip, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent
Constructor and Description |
---|
Menu()
Construct a new Menu.
|
Modifier and Type | Method and Description |
---|---|
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.
|
append, deactivate, insert, prepend
add, getChildren, remove, setBorderWidth
activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, destroy, getAllocatedHeight, getAllocatedWidth, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getPreferredHeightForWidthMinimum, getPreferredHeightForWidthNatural, getPreferredHeightMinimum, getPreferredHeightNatural, getPreferredWidthForHeightMinimum, getPreferredWidthForHeightNatural, getPreferredWidthMinimum, getPreferredWidthNatural, getRequestMode, getRequisition, getSensitive, getStyleContext, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, overrideBackground, overrideColor, overrideFont, queueDraw, queueDrawArea, realize, setAlignHorizontal, setAlignVertical, setCanDefault, setCanFocus, setEvents, setExpandHorizontal, setExpandVertical, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll
public void popup()
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).
public void popup(int x, int y)
getLocation()
if you wish to
place the menu at the "cursor position" rather than where the mouse
pointer is.public void popup(StatusIcon status)
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.public void setAcceleratorGroup(AcceleratorGroup group)
addAcceleratorGroup()
.