Package com.jidesoft.swing
Class JidePopupMenu
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPopupMenu
-
- com.jidesoft.swing.JidePopupMenu
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible,javax.swing.MenuElement,javax.swing.Scrollable
public class JidePopupMenu extends javax.swing.JPopupMenu implements javax.swing.ScrollableThis component extends JPopupMenu and adds a method to display the menu inside the screen even if the mouse pointer is near the edge of the screen. It also puts the menu items into a scroll pane. When there are too many menu items that can't fit into one screen, the scroll pane will scroll up and down so that you can still get to all menu items.- 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
-
-
Field Summary
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description JidePopupMenu()Constructs aJPopupMenuwithout an "invoker".JidePopupMenu(java.lang.String label)Constructs aJPopupMenuwith the specified title.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.awt.PointgetPopupMenuOrigin(java.awt.Component invoker, int x, int y)Figures out the sizes needed to calculate the menu position.java.awt.DimensiongetPreferredScrollableViewportSize()intgetScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)booleangetScrollableTracksViewportHeight()booleangetScrollableTracksViewportWidth()intgetScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)java.lang.StringgetUIClassID()intgetVisibleMenuItemCount()Gets the maximum visible menu item count.voidsetLocation(int x, int y)voidsetVisibleMenuItemCount(int visibleMenuItemCount)Sets the visible menu item count.voidshow(java.awt.Component invoker, int x, int y)Displays the PopUpMenu at a specified position.voidupdateUI()-
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, insert, insert, isBorderPainted, isLightWeightPopupEnabled, isPopupTrigger, isVisible, menuSelectionChanged, pack, paintBorder, paramString, processFocusEvent, processKeyEvent, processKeyEvent, processMouseEvent, remove, removeMenuKeyListener, removePopupMenuListener, setBorderPainted, setDefaultLightWeightPopupEnabled, setInvoker, setLabel, setLightWeightPopupEnabled, setPopupSize, setPopupSize, setSelected, setSelectionModel, setUI, setVisible
-
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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Constructor Detail
-
JidePopupMenu
public JidePopupMenu()
Constructs aJPopupMenuwithout an "invoker".
-
JidePopupMenu
public JidePopupMenu(java.lang.String label)
Constructs aJPopupMenuwith the specified title.- Parameters:
label- the string that a UI may use to display as a title for the popup menu.
-
-
Method Detail
-
getUIClassID
public java.lang.String getUIClassID()
- Overrides:
getUIClassIDin classjavax.swing.JPopupMenu
-
updateUI
public void updateUI()
- Overrides:
updateUIin classjavax.swing.JPopupMenu
-
show
public void show(java.awt.Component invoker, int x, int y)Displays the PopUpMenu at a specified position.- Overrides:
showin classjavax.swing.JPopupMenu- Parameters:
invoker- the component that triggers the eventx- mouse X position on screeny- mouse Y position on screen
-
getPopupMenuOrigin
protected java.awt.Point getPopupMenuOrigin(java.awt.Component invoker, int x, int y)Figures out the sizes needed to calculate the menu position.- Parameters:
invoker- the component that triggers the eventx- mouse X position on screeny- mouse Y position on screen- Returns:
- new position
-
setLocation
public void setLocation(int x, int y)- Overrides:
setLocationin classjavax.swing.JPopupMenu
-
getPreferredScrollableViewportSize
public java.awt.Dimension getPreferredScrollableViewportSize()
- Specified by:
getPreferredScrollableViewportSizein interfacejavax.swing.Scrollable
-
getScrollableUnitIncrement
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)- Specified by:
getScrollableUnitIncrementin interfacejavax.swing.Scrollable
-
getScrollableBlockIncrement
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)- Specified by:
getScrollableBlockIncrementin interfacejavax.swing.Scrollable
-
getScrollableTracksViewportWidth
public boolean getScrollableTracksViewportWidth()
- Specified by:
getScrollableTracksViewportWidthin interfacejavax.swing.Scrollable
-
getScrollableTracksViewportHeight
public boolean getScrollableTracksViewportHeight()
- Specified by:
getScrollableTracksViewportHeightin interfacejavax.swing.Scrollable
-
getVisibleMenuItemCount
public int getVisibleMenuItemCount()
Gets the maximum visible menu item count.- Returns:
- the maximum visible menu item count.
- Since:
- 3.6.2
-
setVisibleMenuItemCount
public void setVisibleMenuItemCount(int visibleMenuItemCount)
Sets the visible menu item count. It will control the popup menu height along with the screen size, whichever is smaller.- Parameters:
visibleMenuItemCount- the maximum menu item count to be shown. -1 means no limit.- Since:
- 3.6.2
-
-