com.alee.laf.menu
Class WebPopupMenu

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 com.alee.laf.menu.WebPopupMenu
All Implemented Interfaces:
LanguageContainerMethods, ShapeProvider, Styleable, SizeMethods<WebPopupMenu>, SwingMethods, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.MenuElement

public class WebPopupMenu
extends javax.swing.JPopupMenu
implements Styleable, ShapeProvider, SizeMethods<WebPopupMenu>, LanguageContainerMethods

This JPopupMenu extension class provides a direct access to WebPopupMenuUI methods. It also has a few additional methods to simplify popup window positioning.

Author:
Mikle Garin
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPopupMenu
javax.swing.JPopupMenu.AccessibleJPopupMenu, javax.swing.JPopupMenu.Separator
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, 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
WebPopupMenu()
          Constructs new popup menu.
WebPopupMenu(java.lang.String styleId)
          Constructs new popup menu with the specified style ID.
 
Method Summary
 void addSeparator()
          Adds separator into menu.
 void addSeparator(int index)
          Adds separator into menu at the specified Z-index.
 java.awt.Color getBorderColor()
          Returns popup border color.
 int getCornerAlignment()
          Returns dropdown corner alignment.
 int getCornerWidth()
          Returns popup dropdown style corner width.
 java.lang.String getLanguageContainerKey()
          Returns language container key for container which implements this interface.
 java.awt.Insets getMargin()
          Returns popup menu content margin.
 int getMenuSpacing()
          Returns spacing between menubar popup menus.
 int getMinimumHeight()
          Returns component minimum height.
 int getMinimumWidth()
          Returns component minimum width.
 PopupMenuPainter getPainter()
          Returns popup menu painter.
 PopupStyle getPopupStyle()
          Returns popup style.
 int getPreferredHeight()
          Returns component preferred height.
 java.awt.Dimension getPreferredSize()
          Returns component preferred size.
 int getPreferredWidth()
          Returns component preferred width.
 int getRound()
          Returns decoration corners rounding.
 float getShadeTransparency()
          Returns popup shade transparency.
 int getShadeWidth()
          Returns decoration shade width.
 java.lang.String getStyleId()
          Returns component style ID.
 float getTransparency()
          Returns popup background transparency.
 WebPopupMenuUI getWebUI()
          Returns Web-UI applied to this class.
 boolean isFixLocation()
          Returns whether popup menu should try to fix its initial location when displayed or not.
 java.awt.Shape provideShape()
          Returns component shape.
 void removeLanguageContainerKey()
          Removes language container key for container which implements this interface.
 WebPopupMenu setBorderColor(java.awt.Color color)
          Sets popup border color.
 void setCornerAlignment(int cornerAlignment)
          Sets dropdown corner alignment.
 WebPopupMenu setCornerWidth(int width)
          Sets popup dropdown style corner width.
 WebPopupMenu setFixLocation(boolean fixLocation)
          Sets whether popup menu should try to fix its initial location when displayed or not.
 void setLanguageContainerKey(java.lang.String key)
          Sets language container key for container which implements this interface.
 WebPopupMenu setMargin(java.awt.Insets margin)
          Sets popup menu content margin.
 WebPopupMenu setMargin(int spacing)
          Sets popup menu content margin.
 WebPopupMenu setMargin(int top, int left, int bottom, int right)
          Sets popup menu content margin.
 WebPopupMenu setMenuSpacing(int spacing)
          Sets spacing between menubar popup menus.
 WebPopupMenu setMinimumHeight(int minimumHeight)
          Sets component minimum height.
 WebPopupMenu setMinimumWidth(int minimumWidth)
          Sets component minimum width.
 WebPopupMenu setPainter(WebPopupMenuPainter painter)
          Sets popup menu painter.
 WebPopupMenu setPopupMenuWay(PopupMenuWay way)
          Assists popup menu to allow it choose the best position relative to invoker.
 WebPopupMenu setPopupStyle(PopupStyle style)
          Sets popup style.
 WebPopupMenu setPreferredHeight(int preferredHeight)
          Sets component preferred height.
 WebPopupMenu setPreferredWidth(int preferredWidth)
          Sets component preferred width.
 WebPopupMenu setRound(int round)
          Sets decoration corners rounding.
 WebPopupMenu setShadeTransparency(float opacity)
          Sets popup shade transparency.
 WebPopupMenu setShadeWidth(int shadeWidth)
          Sets decoration shade width.
 void setStyleId(java.lang.String id)
          Sets custom component style ID.
 WebPopupMenu setTransparency(float transparency)
          Sets popup background transparency.
 WebPopupMenu showAbove(java.awt.Component invoker)
          Displays popup menu above the invoker component starting at its leading side.
 WebPopupMenu showAboveEnd(java.awt.Component invoker)
          Displays popup menu above the invoker component starting at its trailing side.
 WebPopupMenu showAboveMiddle(java.awt.Component invoker)
          Displays popup menu above the invoker component at its middle.
 WebPopupMenu showAboveStart(java.awt.Component invoker)
          Displays popup menu above the invoker component starting at its leading side.
 WebPopupMenu showBelow(java.awt.Component invoker)
          Displays popup menu under the invoker component starting at its leading side.
 WebPopupMenu showBelowEnd(java.awt.Component invoker)
          Displays popup menu under the invoker component starting at its trailing side.
 WebPopupMenu showBelowMiddle(java.awt.Component invoker)
          Displays popup menu under the invoker component at its middle.
 WebPopupMenu showBelowStart(java.awt.Component invoker)
          Displays popup menu under the invoker component starting at its leading side.
 void updateUI()
          Installs a Web-UI into this component.
 
Methods inherited from class javax.swing.JPopupMenu
add, add, add, addMenuKeyListener, addPopupMenuListener, createActionChangeListener, createActionComponent, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getComponent, getComponentAtIndex, getComponentIndex, getDefaultLightWeightPopupEnabled, getInvoker, getLabel, 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, setVisible, show
 
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, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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
 

Constructor Detail

WebPopupMenu

public WebPopupMenu()
Constructs new popup menu.


WebPopupMenu

public WebPopupMenu(java.lang.String styleId)
Constructs new popup menu with the specified style ID.

Parameters:
styleId - popup menu style ID
Method Detail

addSeparator

public void addSeparator()
Adds separator into menu.

Overrides:
addSeparator in class javax.swing.JPopupMenu

addSeparator

public void addSeparator(int index)
Adds separator into menu at the specified Z-index.

Parameters:
index - separator Z-index

showAbove

public WebPopupMenu showAbove(java.awt.Component invoker)
Displays popup menu above the invoker component starting at its leading side. This method takes into account component orientation.

Parameters:
invoker - invoker component
Returns:
this popup menu

showAboveStart

public WebPopupMenu showAboveStart(java.awt.Component invoker)
Displays popup menu above the invoker component starting at its leading side. This method takes into account component orientation.

Parameters:
invoker - invoker component
Returns:
this popup menu

showAboveMiddle

public WebPopupMenu showAboveMiddle(java.awt.Component invoker)
Displays popup menu above the invoker component at its middle.

Parameters:
invoker - invoker component
Returns:
this popup menu

showAboveEnd

public WebPopupMenu showAboveEnd(java.awt.Component invoker)
Displays popup menu above the invoker component starting at its trailing side. This method takes into account component orientation.

Parameters:
invoker - invoker component
Returns:
this popup menu

showBelow

public WebPopupMenu showBelow(java.awt.Component invoker)
Displays popup menu under the invoker component starting at its leading side. This method also takes into account component orientation.

Parameters:
invoker - invoker component
Returns:
this popup menu

showBelowStart

public WebPopupMenu showBelowStart(java.awt.Component invoker)
Displays popup menu under the invoker component starting at its leading side. This method takes into account component orientation.

Parameters:
invoker - invoker component
Returns:
this popup menu

showBelowMiddle

public WebPopupMenu showBelowMiddle(java.awt.Component invoker)
Displays popup menu under the invoker component at its middle.

Parameters:
invoker - invoker component
Returns:
this popup menu

showBelowEnd

public WebPopupMenu showBelowEnd(java.awt.Component invoker)
Displays popup menu under the invoker component starting at its trailing side. This method takes into account component orientation.

Parameters:
invoker - invoker component
Returns:
this popup menu

getMargin

public java.awt.Insets getMargin()
Returns popup menu content margin.

Overrides:
getMargin in class javax.swing.JPopupMenu
Returns:
popup menu content margin

setMargin

public WebPopupMenu setMargin(java.awt.Insets margin)
Sets popup menu content margin.

Parameters:
margin - popup menu content margin
Returns:
this popup menu

setMargin

public WebPopupMenu setMargin(int top,
                              int left,
                              int bottom,
                              int right)
Sets popup menu content margin.

Parameters:
top - top popup menu content margin
left - left popup menu content margin
bottom - bottom popup menu content margin
right - right popup menu content margin
Returns:
this popup menu

setMargin

public WebPopupMenu setMargin(int spacing)
Sets popup menu content margin.

Parameters:
spacing - popup menu content margin
Returns:
this popup menu

getPainter

public PopupMenuPainter getPainter()
Returns popup menu painter.

Returns:
popup menu painter

setPainter

public WebPopupMenu setPainter(WebPopupMenuPainter painter)
Sets popup menu painter.

Parameters:
painter - new popup menu painter
Returns:
this popup menu

getMenuSpacing

public int getMenuSpacing()
Returns spacing between menubar popup menus.

Returns:
spacing between menubar popup menus

setMenuSpacing

public WebPopupMenu setMenuSpacing(int spacing)
Sets spacing between menubar popup menus.

Parameters:
spacing - new spacing between menubar popup menus
Returns:
this popup menu

isFixLocation

public boolean isFixLocation()
Returns whether popup menu should try to fix its initial location when displayed or not.

Returns:
true if popup menu should try to fix its initial location when displayed, false otherwise

setFixLocation

public WebPopupMenu setFixLocation(boolean fixLocation)
Sets whether popup menu should try to fix its initial location when displayed or not.

Parameters:
fixLocation - whether popup menu should try to fix its initial location when displayed or not
Returns:
this popup menu

setPopupMenuWay

public WebPopupMenu setPopupMenuWay(PopupMenuWay way)
Assists popup menu to allow it choose the best position relative to invoker. Its value nullified right after first usage to avoid popup menu display issues in future.

Parameters:
way - approximate popup menu display way
Returns:
this popup menu

getPopupStyle

public PopupStyle getPopupStyle()
Returns popup style.

Returns:
popup style

setPopupStyle

public WebPopupMenu setPopupStyle(PopupStyle style)
Sets popup style.

Parameters:
style - new popup style
Returns:
this popup menu

getBorderColor

public java.awt.Color getBorderColor()
Returns popup border color.

Returns:
popup border color

setBorderColor

public WebPopupMenu setBorderColor(java.awt.Color color)
Sets popup border color.

Parameters:
color - new popup border color
Returns:
this popup menu

getRound

public int getRound()
Returns decoration corners rounding.

Returns:
decoration corners rounding

setRound

public WebPopupMenu setRound(int round)
Sets decoration corners rounding.

Parameters:
round - decoration corners rounding
Returns:
this popup menu

getShadeWidth

public int getShadeWidth()
Returns decoration shade width.

Returns:
decoration shade width

setShadeWidth

public WebPopupMenu setShadeWidth(int shadeWidth)
Sets decoration shade width.

Parameters:
shadeWidth - decoration shade width
Returns:
this popup menu

getShadeTransparency

public float getShadeTransparency()
Returns popup shade transparency.

Returns:
popup shade transparency

setShadeTransparency

public WebPopupMenu setShadeTransparency(float opacity)
Sets popup shade transparency.

Parameters:
opacity - new popup shade transparency
Returns:
this popup menu

getCornerWidth

public int getCornerWidth()
Returns popup dropdown style corner width.

Returns:
popup dropdown style corner width

setCornerWidth

public WebPopupMenu setCornerWidth(int width)
Sets popup dropdown style corner width.

Parameters:
width - popup dropdown style corner width
Returns:
this popup menu

getCornerAlignment

public int getCornerAlignment()
Returns dropdown corner alignment.

Returns:
dropdown corner alignment

setCornerAlignment

public void setCornerAlignment(int cornerAlignment)
Sets dropdown corner alignment.

Parameters:
cornerAlignment - dropdown corner alignment

getTransparency

public float getTransparency()
Returns popup background transparency.

Returns:
popup background transparency

setTransparency

public WebPopupMenu setTransparency(float transparency)
Sets popup background transparency.

Parameters:
transparency - popup background transparency
Returns:
this popup menu

getStyleId

public java.lang.String getStyleId()
Returns component style ID. Custom ID can be specified to override default component style using "setStyleId" method. If style for such custom ID is not found in skin descriptor then default style for that component is used.

Specified by:
getStyleId in interface Styleable
Returns:
component style ID

setStyleId

public void setStyleId(java.lang.String id)
Sets custom component style ID. If style for such custom ID is not found in skin descriptor default style will be used for that component. This method forces component to instantly use component style with the specified ID.

Specified by:
setStyleId in interface Styleable
Parameters:
id - custom component style ID

provideShape

public java.awt.Shape provideShape()
Returns component shape.

Specified by:
provideShape in interface ShapeProvider
Returns:
component shape

getWebUI

public WebPopupMenuUI getWebUI()
Returns Web-UI applied to this class.

Returns:
Web-UI applied to this class

updateUI

public void updateUI()
Installs a Web-UI into this component.

Overrides:
updateUI in class javax.swing.JPopupMenu

getPreferredWidth

public int getPreferredWidth()
Returns component preferred width.

Specified by:
getPreferredWidth in interface SizeMethods<WebPopupMenu>
Returns:
component preferred width

setPreferredWidth

public WebPopupMenu setPreferredWidth(int preferredWidth)
Sets component preferred width. Pass -1 to let component choose preferred width on its own.

Specified by:
setPreferredWidth in interface SizeMethods<WebPopupMenu>
Parameters:
preferredWidth - new component preferred width
Returns:
modified component

getPreferredHeight

public int getPreferredHeight()
Returns component preferred height.

Specified by:
getPreferredHeight in interface SizeMethods<WebPopupMenu>
Returns:
component preferred height

setPreferredHeight

public WebPopupMenu setPreferredHeight(int preferredHeight)
Sets component preferred height. Pass -1 to let component choose preferred height on its own.

Specified by:
setPreferredHeight in interface SizeMethods<WebPopupMenu>
Parameters:
preferredHeight - new component preferred height
Returns:
modified component

getMinimumWidth

public int getMinimumWidth()
Returns component minimum width.

Specified by:
getMinimumWidth in interface SizeMethods<WebPopupMenu>
Returns:
component minimum width

setMinimumWidth

public WebPopupMenu setMinimumWidth(int minimumWidth)
Sets component minimum width. Pass -1 to let component choose minimum width on its own.

Specified by:
setMinimumWidth in interface SizeMethods<WebPopupMenu>
Parameters:
minimumWidth - new component minimum width
Returns:
modified component

getMinimumHeight

public int getMinimumHeight()
Returns component minimum height.

Specified by:
getMinimumHeight in interface SizeMethods<WebPopupMenu>
Returns:
component minimum height

setMinimumHeight

public WebPopupMenu setMinimumHeight(int minimumHeight)
Sets component minimum height. Pass -1 to let component choose minimum height on its own.

Specified by:
setMinimumHeight in interface SizeMethods<WebPopupMenu>
Parameters:
minimumHeight - new component minimum height
Returns:
modified component

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns component preferred size.

Specified by:
getPreferredSize in interface SizeMethods<WebPopupMenu>
Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
component preferred size

setLanguageContainerKey

public void setLanguageContainerKey(java.lang.String key)
Sets language container key for container which implements this interface.

Specified by:
setLanguageContainerKey in interface LanguageContainerMethods
Parameters:
key - language container key

removeLanguageContainerKey

public void removeLanguageContainerKey()
Removes language container key for container which implements this interface.

Specified by:
removeLanguageContainerKey in interface LanguageContainerMethods

getLanguageContainerKey

public java.lang.String getLanguageContainerKey()
Returns language container key for container which implements this interface.

Specified by:
getLanguageContainerKey in interface LanguageContainerMethods
Returns:
language container key for container which implements this interface