com.tensegrity.gui.swing.control
Class PopupMenu

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPopupMenu
                  extended bycom.tensegrity.gui.swing.control.PopupMenu
All Implemented Interfaces:
javax.accessibility.Accessible, BasicComponent, Evaluable, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.MenuElement, PopupMenuMarkup, java.io.Serializable

public class PopupMenu
extends javax.swing.JPopupMenu
implements PopupMenuMarkup

The SwingPopupMenu implementation extends the default swing implementation about the feature to check whether menu items should be en- or disabled according to the state of the associated item. This class basically overrides the JPopupMenu.show(java.awt.Component, int, int)- method to check the state before calling the base class.

Version:
$Id: PopupMenu.java,v 1.11 2005/09/13 13:49:01 BurkhardWick Exp $
Author:
GillesIachelini
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPopupMenu
javax.swing.JPopupMenu.AccessibleJPopupMenu, javax.swing.JPopupMenu.Separator
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
PopupMenu()
          Creates the default SwingPopupMenu.
PopupMenu(java.lang.String label)
          Creates the default SwingPopupMenu with the given string used as label.
 
Method Summary
 java.awt.Component add(java.awt.Component c)
           
 java.awt.Component add(java.awt.Component c, int index)
           
 void add(java.awt.Component comp, java.lang.Object constraints)
           
 void add(java.awt.Component comp, java.lang.Object constraints, int index)
           
 javax.swing.JMenuItem add(javax.swing.JMenuItem menuItem)
           
 void add(java.awt.PopupMenu popup)
           
 java.awt.Component add(java.lang.String name, java.awt.Component comp)
           
 void addSeparator()
          Appends a separator of default size to the end of the tool bar.
 void applyEvList()
          Tells the component to apply its UIItemEvaluationList.
 BasicComponent getParentComponent()
          Returns the parent Component of this instance.
protected  java.awt.Point getPopupMenuOrigin(java.awt.Component invoker, int desiredX, int desiredY)
          Compute the origin for the JMenu's popup menu.
 void installEvList()
          Tells the component to setup its internal state.
 void show(java.awt.Component invoker, int x, int y)
          This method was overwritten to add a state-updater to the contained menuitems.
 
Methods inherited from class javax.swing.JPopupMenu
add, add, addPopupMenuListener, createActionChangeListener, createActionComponent, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getComponent, getComponentAtIndex, getComponentIndex, getDefaultLightWeightPopupEnabled, getInvoker, getLabel, getMargin, getPopupMenuListeners, getSelectionModel, getSubElements, getUI, getUIClassID, insert, insert, isBorderPainted, isLightWeightPopupEnabled, isPopupTrigger, isVisible, menuSelectionChanged, pack, paintBorder, paramString, processFocusEvent, processKeyEvent, processKeyEvent, processMouseEvent, remove, removePopupMenuListener, setBorderPainted, setDefaultLightWeightPopupEnabled, setInvoker, setLabel, setLightWeightPopupEnabled, setLocation, setPopupSize, setPopupSize, setSelected, setSelectionModel, setUI, setVisible, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
 
Methods inherited from interface com.tensegrity.gui.component.BasicComponent
getHeight, getWidth, repaint
 

Constructor Detail

PopupMenu

public PopupMenu()
Creates the default SwingPopupMenu.


PopupMenu

public PopupMenu(java.lang.String label)
Creates the default SwingPopupMenu with the given string used as label.

Parameters:
label - text for the label of this SwingPopupMenu.
Method Detail

add

public java.awt.Component add(java.awt.Component c)

add

public java.awt.Component add(java.awt.Component c,
                              int index)

add

public javax.swing.JMenuItem add(javax.swing.JMenuItem menuItem)

add

public void add(java.awt.Component comp,
                java.lang.Object constraints)

add

public void add(java.awt.Component comp,
                java.lang.Object constraints,
                int index)

add

public java.awt.Component add(java.lang.String name,
                              java.awt.Component comp)

add

public void add(java.awt.PopupMenu popup)

addSeparator

public void addSeparator()
Appends a separator of default size to the end of the tool bar. The default size is determined by the current look and feel. This method ignores the call, if there is already a separator at the end of the component list.

See Also:
JPopupMenu.addSeparator()

getPopupMenuOrigin

protected java.awt.Point getPopupMenuOrigin(java.awt.Component invoker,
                                            int desiredX,
                                            int desiredY)
Compute the origin for the JMenu's popup menu. This method takes into account whether the menu should popup on the very right of the desktop or bottom. This requires a correction of the x or y coordinate of the resulting Point instance.

Parameters:
invoker - the invoker of the popup, required to calculate screen coordinates.
desiredX - the original x position for the menu.
desiredY - the original y position for the menu.
Returns:
a Point in the coordinate space of the menu instance which should be used as the origin of the JMenu's popup menu.

show

public void show(java.awt.Component invoker,
                 int x,
                 int y)
This method was overwritten to add a state-updater to the contained menuitems. Each time the menu has to made visible the isEnabled state of the contained items gets updated.

See Also:
JMenu.setPopupMenuVisible(boolean)

getParentComponent

public BasicComponent getParentComponent()
Description copied from interface: BasicComponent
Returns the parent Component of this instance.

Specified by:
getParentComponent in interface BasicComponent
Returns:
the parent component or null if no parent exists.

applyEvList

public void applyEvList()
Description copied from interface: Evaluable
Tells the component to apply its UIItemEvaluationList.

Specified by:
applyEvList in interface Evaluable

installEvList

public void installEvList()
Description copied from interface: Evaluable
Tells the component to setup its internal state.

Specified by:
installEvList in interface Evaluable


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.