|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPopupMenu
ilog.views.swing.IlvSimplePopupMenu
public class IlvSimplePopupMenu
A simple version of a JPopupMenu component.
IlvPopupMenuManager,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JPopupMenu |
|---|
JPopupMenu.AccessibleJPopupMenu, JPopupMenu.Separator |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
static String |
ACTION_CHECK_KEY
Key for the action property that indicates whether the menu item is checked or unchecked. |
static String |
ACTION_GROUP_KEY
Key for the action property that indicates whether the menu item is in a action group. |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
IlvSimplePopupMenu()
Constructs a IlvSimplePopupMenu. |
|
IlvSimplePopupMenu(String title,
Action[] actions)
Constructs a IlvSimplePopupMenu from an array of actions. |
|
IlvSimplePopupMenu(String title,
String[] actions,
ResourceBundle bundle,
ActionListener actionListener)
Constructs a IlvSimplePopupMenu from an array of actions. |
|
IlvSimplePopupMenu(String title,
String actionspec,
ResourceBundle bundle,
ActionListener actionListener)
Constructs a IlvSimplePopupMenu from a string specification. |
|
| Method Summary | |
|---|---|
void |
addActions(Action[] actions)
Adds the input actions as menu items to this popup menu. |
void |
addActions(String[] actions,
ResourceBundle bundle,
ActionListener actionListener)
Adds actions to this popup menu. |
void |
addActions(String actionspec,
char itemDelimiter,
char groupStartDelimiter,
char groupEndDelimiter,
ResourceBundle bundle,
ActionListener actionListener)
Adds actions to this popup menu. |
protected void |
afterDisplay(IlvPopupMenuContext context)
This method is called after the popup menu is made invisible. |
protected void |
beforeDisplay(IlvPopupMenuContext context)
This method is called before the popup menu is displayed. |
JMenuItem |
getItemForActionCommand(String actionCommand)
Returns the menu item for a given action command. |
JMenuItem |
getItemForText(String label)
Returns the menu item for a given menu item text label. |
void |
setVisible(boolean visible)
Sets the visibility of the popup menu. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String ACTION_CHECK_KEY
Boolean.
Action.putValue(java.lang.String, java.lang.Object)public static final String ACTION_GROUP_KEY
String.
Action.putValue(java.lang.String, java.lang.Object)| Constructor Detail |
|---|
public IlvSimplePopupMenu()
IlvSimplePopupMenu.
public IlvSimplePopupMenu(String title,
String actionspec,
ResourceBundle bundle,
ActionListener actionListener)
IlvSimplePopupMenu from a string specification.
Here is an example specification:
"Save | Load | - | { Mode1 | Mode2 | Mode3 }"
The menu items are separated by the bar (|) character.
Groups of radio menu items (i.e., menu items with a check mark so that
only one of them is checked) are enclosed in the opening bracket ({)
and the closing bracket (}).
The dash character (-) adds a separator line between the menu items.
If a resource bundle is passed as argument, the menu items are translated by the resource bundle. For each menu entry, additional options can be specified using the '@' option separator. Here is an example which specifies tooltips for the menu items:
"Save @T=Save to file | Load @T=Load from file"See the method
addActions(String, char, char, char, ResourceBundle, ActionListener)
for the explanation about the specification format.
title - The title of the popup menu. This can be null.actionspec - The string specification of the actions.bundle - The resource bundle for i18nactionListener - The action listener that receives all action events
from all menu items of this menu.Action
public IlvSimplePopupMenu(String title,
String[] actions,
ResourceBundle bundle,
ActionListener actionListener)
IlvSimplePopupMenu from an array of actions.
Each action is specified by a string entry in the input array.
Here is an example string:
"Hello @M=H @I=hello.gif @T=Hello Tooltip"See
addActions(String[], ResourceBundle, ActionListener)
for the explanation about the specification format.
title - The title of the popup menu. This can be null.actions - The string specification of the actions.bundle - The resource bundle for i18nactionListener - The action listener that receives all action events
from all menu items of this menu.Action
public IlvSimplePopupMenu(String title,
Action[] actions)
IlvSimplePopupMenu from an array of actions.
Each action must have the Action.NAME property, which is used as
label of the corresponding menu item. Furthermore, the following optional
action properties are recognized:
Action.MNEMONIC_KEY
Action.SHORT_DESCRIPTION
Action.SMALL_ICON
Action.ACTION_COMMAND_KEY
ACTION_CHECK_KEY
ACTION_GROUP_KEY
null entry in the actions array generates
a separator line in the menu.
title - The title of the popup menu. This can be null.actions - The actions of the popup menu.Action| Method Detail |
|---|
public void addActions(String actionspec,
char itemDelimiter,
char groupStartDelimiter,
char groupEndDelimiter,
ResourceBundle bundle,
ActionListener actionListener)
"Save | Load | - | { Mode1 | Mode2 | Mode3 }"
The menu items are separated by the itemDelimiter character.
In the example, the bar (|) is used as item delimiter.
Groups of radio menu items (i.e., menu items with a check mark so that
only one of them is checked) must be enclosed in the
groupStartDelimiter and groupEndDelimiter.
In the example, the opening bracket ({) starts a group, and the closing
bracket (}) end the group.
The dash character (-) adds a separator line between the menu items.
If a resource bundle is passed as argument, the menu items are translated by the resource bundle. For each menu entry, additional options can be specified using the '@' option separator. Here is an example which specifies tooltips for the menu items:
"Save @T=Save to file | Load @T=Load from file"See the method
addActions(String[], ResourceBundle, ActionListener)
for details about the specification with '@'.
Note that blancs are significant in the specification, so they should
not be used as white space. The only exception is the single blanc before
and after the delimiters, and before the '@' character. These blancs are
optional, and they are ignored if there are there.
actionspec - The string specification of the actions.itemDelimiter - The character that separates the menu items.groupStartDelimiter - The character that starts a radio group.groupEndDelimiter - The character that finishes a radio group.bundle - The resource bundle for i18nactionListener - The action listener that receives all action events
from all menu items of this menu.Action
public void addActions(String[] actions,
ResourceBundle bundle,
ActionListener actionListener)
"Hello @M=H @I=hello.gif @T=Hello Tooltip"The separator character is '@'. The first entry is the mandatory title of the corresponding menu item. Possible optional parts of the specification are:
@M= The mnemonic, as parsed by javax.swing.KeyStroke.
If the resource bundle is not null, the mnemonic is first translated
by the resource bundle, and then parsed by javax.swing.KeyStroke.
@I= The icon file. It makes several attempts to load
the icon file. It first tries to load the icon
image as resource (relative to the path of the action listener),
then as file name, and finally as fully specified URL.
URL.
@T= The tooltip.
If the resource bundle is not null, the tooltip is translated
by the resource bundle.
@A= The action command.
@C= Whether the action is checked or unchecked.
The possible values are true and false.
If this option is specified, the action is checkable; if the option
is missing, the action is not checkable.
@G= The group.
If the group is specified, the action behaves like a radio checkbox.
If no group is specified, the action behaves like a normal action.
@ which is optional.
A null entry in the actions array generates
a separator line in the menu.
actions - The string specification of the actions.bundle - The resource bundle for i18nactionListener - The action listener that receives all action events
from all menu items of this menu.Actionpublic void addActions(Action[] actions)
Action.NAME property, which is used as
label of the corresponding menu item. Furthermore, the following optional
action properties are recognized:
Action.MNEMONIC_KEY
Action.SHORT_DESCRIPTION
Action.SMALL_ICON
Action.ACTION_COMMAND_KEY
ACTION_CHECK_KEY
ACTION_GROUP_KEY
null entry in the actions array generates
a separator line in the menu.
Ratio menu item groups are only recognized if they are added in one step.
This means, if addActions is called multiple times, then
each time, different groups are created for each call even if the same
group name is used in the multiple calls.
actions - The actions of the popup menu.Actionpublic JMenuItem getItemForText(String label)
null if no menu item is found for the text label.
label - The text label.public JMenuItem getItemForActionCommand(String actionCommand)
null if no menu item is found for the action
command.
actionCommand - The action command.public void setVisible(boolean visible)
setVisible in class JPopupMenuvisible - true to make the popup visible, or false to hide it.protected void beforeDisplay(IlvPopupMenuContext context)
super.beforeDisplay(context).
It allows to configure the popup menu according to the popup context,
for instance to enable or disable menu items, or to update the checked
status of the menu items.
The default implementation updates the menu items according to the
state of the corresponding actions.
context - The popup menu contextprotected void afterDisplay(IlvPopupMenuContext context)
super.afterDisplay(context).
It allows to cleanup the popup menu according to the popup context.
context - The popup menu context
|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||