|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbuoy.event.EventSource
buoy.widget.Widget
buoy.widget.WidgetContainer
buoy.widget.BPopupMenu
public class BPopupMenu
A BPopupMenu is a WidgetContainer corresponding to a popup menu. It is typically displayed in
response to a WidgetMouseEvent
whose isPopupTrigger()
method returns true. The exact conditions which represent a popup trigger are platform specific.
The easiest way to add a popup menu to a widget is to invoke
widget.addEventLink(WidgetMouseEvent.class, popup, "show");
on the widget. This will automatically take care of showing the menu whenever the user performs
the appropriate action. Alternatively, you can write your own code to listen for the event and
call show()
on the popup menu. For example, you might want to disable certain
menu items before showing it based on the position of the mouse click.
Constructor Summary | |
---|---|
BPopupMenu()
Create a new BPopupMenu. |
Method Summary | |
---|---|
void |
add(MenuWidget widget)
Add a MenuWidget (typically a BMenuItem or BMenu) to the end of the menu. |
void |
add(MenuWidget widget,
int index)
Add a MenuWidget (typically a BMenuItem or another BMenu) to the menu. |
void |
addSeparator()
Add a dividing line (a BSeparator) to the end of the menu. |
MenuWidget |
getChild(int i)
Get the i'th child of this container. |
int |
getChildCount()
Get the number of children in this container. |
java.util.Collection<Widget> |
getChildren()
Get a Collection containing all child Widgets of this container. |
javax.swing.JPopupMenu |
getComponent()
Get the java.awt.Component corresponding to this Widget. |
void |
layoutChildren()
Layout the child Widgets. |
void |
remove(Widget widget)
Remove a child Widget from this container. |
void |
removeAll()
Remove all child Widgets from this container. |
void |
show(Widget widget,
int x,
int y)
Display the popup menu over another Widget. |
void |
show(WidgetMouseEvent event)
Display the popup menu in response to an event. |
Methods inherited from class buoy.widget.WidgetContainer |
---|
isOpaque, setOpaque |
Methods inherited from class buoy.widget.Widget |
---|
addEventLink, dispatchEvent, getBackground, getBounds, getCursor, getFont, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible |
Methods inherited from class buoy.event.EventSource |
---|
addEventLink, addEventLink, removeEventLink |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BPopupMenu()
Method Detail |
---|
public javax.swing.JPopupMenu getComponent()
Widget
getComponent
in class Widget
public void show(Widget widget, int x, int y)
widget
- the Widget over which to display the popup menux
- the x coordinate at which to display the popup menuy
- the y coordinate at which to display the popup menupublic void show(WidgetMouseEvent event)
event.isPopupTrigger()
returns false, this method returns without doing anything. Otherwise it shows the popup,
determining the appropriate location based on information stored in the event.
This version of show() is provided as a convenience. It allows you to very easily add a popup menu to a Widget by invoking
widget.addEventLink(WidgetMouseEvent.class, popup, "show");
event
- the user event which is triggering the popup menupublic void add(MenuWidget widget)
public void add(MenuWidget widget, int index)
widget
- the MenuWidget to addindex
- the position at which to add itpublic void addSeparator()
public int getChildCount()
getChildCount
in class WidgetContainer
public MenuWidget getChild(int i)
public java.util.Collection<Widget> getChildren()
getChildren
in class WidgetContainer
public void remove(Widget widget)
remove
in class WidgetContainer
public void removeAll()
removeAll
in class WidgetContainer
public void layoutChildren()
layoutChildren
in class WidgetContainer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |