public class SwingPopupMenuBuilder extends AbstractPopupMenuBuilder
A specialized implementation of the PopupMenuBuilder
interface
for constructing Swing popup menus.
This implementation creates a javax.swing.JPopupMenu
object when
a new builder instance is created. The several add()
methods
populate this menu. They expect that objects compatible with Swing are passed
as parameters (e.g. Swing actions or Swing menu components).
The create()
method returns the current popup menu. It also
displays the menu for the affected component (this component and the location
where to display the popup must be specified at construction time).
Constructor and Description |
---|
SwingPopupMenuBuilder(ActionManager actMan,
ActionBuilder builder,
MouseEvent event)
Creates a new instance of
SwingPopupMenuBuilder and initializes
it with information about the action manager to be delegated to and the
mouse event that triggered the invocation of this builder. |
SwingPopupMenuBuilder(MouseEvent event)
Deprecated.
Use the constructor which expects information about an
ActionManager ; this constructor only creates a partly
initialized object. |
Modifier and Type | Method and Description |
---|---|
Object |
create()
Displays the popup menu constructed by this builder.
|
protected JPopupMenu |
getMenu()
Returns the menu that is constructed by this builder.
|
protected Object |
getMenuUnderConstruction()
Returns the menu which is currently under construction.
|
MouseEvent |
getTriggeringEvent()
Returns the event that triggered the invocation of this builder.
|
protected void |
showMenu(JPopupMenu m)
Displays the specified popup menu.
|
addAction, addSeparator, addSubMenu, getActionBuilder, getActionManager, subMenuBuilder
public SwingPopupMenuBuilder(ActionManager actMan, ActionBuilder builder, MouseEvent event)
SwingPopupMenuBuilder
and initializes
it with information about the action manager to be delegated to and the
mouse event that triggered the invocation of this builder.actMan
- the ActionManager
builder
- the ActionBuilder
event
- the triggering event (must not be null)IllegalArgumentException
- if the event is null@Deprecated public SwingPopupMenuBuilder(MouseEvent event)
ActionManager
; this constructor only creates a partly
initialized object.SwingPopupMenuBuilder
and initializes
it with the triggering mouse event.event
- the triggering event (must not be null)IllegalArgumentException
- if the event is nullpublic MouseEvent getTriggeringEvent()
public Object create()
protected JPopupMenu getMenu()
protected void showMenu(JPopupMenu m)
create()
with the current menu. This implementation displays
the popup menu as specified by the triggering event.m
- the menu to displayprotected Object getMenuUnderConstruction()
AbstractPopupMenuBuilder
ActionManager
in order to add new elements to it.getMenuUnderConstruction
in class AbstractPopupMenuBuilder
Copyright © 2016 The JGUIraffe Team. All rights reserved.