ilog.views.swing
Class IlvSimplePopupMenu

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPopupMenu
                  extended by ilog.views.swing.IlvSimplePopupMenu
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, MenuElement

public class IlvSimplePopupMenu
extends JPopupMenu

A simple version of a JPopupMenu component.

Since:
JViews 7.5
See Also:
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 javax.swing.JPopupMenu
add, add, add, addMenuKeyListener, addPopupMenuListener, addSeparator, createActionChangeListener, createActionComponent, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getComponent, getComponentAtIndex, getComponentIndex, getDefaultLightWeightPopupEnabled, getInvoker, getLabel, getMargin, getMenuKeyListeners, getPopupMenuListeners, getSelectionModel, getSubElements, getUI, getUIClassID, insert, insert, isBorderPainted, isLightWeightPopupEnabled, isPopupTrigger, isVisible, menuSelectionChanged, pack, paintBorder, paramString, processFocusEvent, processKeyEvent, processKeyEvent, processMouseEvent, remove, removeMenuKeyListener, removePopupMenuListener, setBorderPainted, setDefaultLightWeightPopupEnabled, setInvoker, setLabel, setLightWeightPopupEnabled, setLocation, setPopupSize, setPopupSize, setSelected, setSelectionModel, setUI, show, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ACTION_CHECK_KEY

public static final String ACTION_CHECK_KEY
Key for the action property that indicates whether the menu item is checked or unchecked. The value stored for this key is of type Boolean.

See Also:
Action.putValue(java.lang.String, java.lang.Object)

ACTION_GROUP_KEY

public static final String ACTION_GROUP_KEY
Key for the action property that indicates whether the menu item is in a action group. The value stored for this key is of type String.

See Also:
Action.putValue(java.lang.String, java.lang.Object)
Constructor Detail

IlvSimplePopupMenu

public IlvSimplePopupMenu()
Constructs a IlvSimplePopupMenu.


IlvSimplePopupMenu

public IlvSimplePopupMenu(String title,
                          String actionspec,
                          ResourceBundle bundle,
                          ActionListener actionListener)
Constructs a 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.

Parameters:
title - The title of the popup menu. This can be null.
actionspec - The string specification of the actions.
bundle - The resource bundle for i18n
actionListener - The action listener that receives all action events from all menu items of this menu.
See Also:
Action

IlvSimplePopupMenu

public IlvSimplePopupMenu(String title,
                          String[] actions,
                          ResourceBundle bundle,
                          ActionListener actionListener)
Constructs a 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.

Parameters:
title - The title of the popup menu. This can be null.
actions - The string specification of the actions.
bundle - The resource bundle for i18n
actionListener - The action listener that receives all action events from all menu items of this menu.
See Also:
Action

IlvSimplePopupMenu

public IlvSimplePopupMenu(String title,
                          Action[] actions)
Constructs a 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: A null entry in the actions array generates a separator line in the menu.

Parameters:
title - The title of the popup menu. This can be null.
actions - The actions of the popup menu.
See Also:
Action
Method Detail

addActions

public void addActions(String actionspec,
                       char itemDelimiter,
                       char groupStartDelimiter,
                       char groupEndDelimiter,
                       ResourceBundle bundle,
                       ActionListener actionListener)
Adds actions to this popup menu. The actions are specified by a string. Here is an example string:
 "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.

Parameters:
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 i18n
actionListener - The action listener that receives all action events from all menu items of this menu.
See Also:
Action

addActions

public void addActions(String[] actions,
                       ResourceBundle bundle,
                       ActionListener actionListener)
Adds actions to this popup menu. 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"
 
The separator character is '@'. The first entry is the mandatory title of the corresponding menu item. Possible optional parts of the specification are:

addActions

public void addActions(Action[] actions)
Adds the input actions as menu items to this popup menu. 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: A 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.

Parameters:
actions - The actions of the popup menu.
See Also:
Action

getItemForText

public JMenuItem getItemForText(String label)
Returns the menu item for a given menu item text label. It returns null if no menu item is found for the text label.

Parameters:
label - The text label.

getItemForActionCommand

public JMenuItem getItemForActionCommand(String actionCommand)
Returns the menu item for a given action command. This requires that action commands are specified for the menu items. It returns null if no menu item is found for the action command.

Parameters:
actionCommand - The action command.

setVisible

public void setVisible(boolean visible)
Sets the visibility of the popup menu.

Overrides:
setVisible in class JPopupMenu
Parameters:
visible - true to make the popup visible, or false to hide it.

beforeDisplay

protected void beforeDisplay(IlvPopupMenuContext context)
This method is called before the popup menu is displayed. You can override this method to add specific functionality. However, your overridden version must start with a call of 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.

Parameters:
context - The popup menu context

afterDisplay

protected void afterDisplay(IlvPopupMenuContext context)
This method is called after the popup menu is made invisible. You can override this method to add specific functionality. However, your overridden version must call super.afterDisplay(context). It allows to cleanup the popup menu according to the popup context.

Parameters:
context - The popup menu context


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.