This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing
class JPopupMenu

java.lang.Object extended by java.awt.Component extended by java.awt.Container extended by javax.swing.JComponent extended by javax.swing.JPopupMenu
All Implemented Interfaces:
MenuContainer, ImageObserver, Serializable, Accessible, MenuElement, TransferHandler.HasGetTransferHandler
Direct Known Subclasses:
BasicComboPopup

Most common way to construct:

JPopupMenu popup = new JPopupMenu();

Based on 40 examples


public class JPopupMenu
extends JComponent
implements Accessible, MenuElement

An implementation of a popup menu -- a small window that pops up and displays a series of choices. A JPopupMenu is used for the menu that appears when the user selects an item on the menu bar. It is also used for "pull-right" menu that appears when the selects a menu item that activates it. Finally, a JPopupMenu can also be used anywhere else you want a menu to appear. For example, when the user right-clicks in a specified area.

For information and examples of using popup menus, see How to Use Menus in The Java Tutorial.

Warning: Swing is not thread safe. For more information see Swing's Threading Policy.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}.


Nested Class Summary
protected class

           This class implements accessibility support for the JPopupMenu class.
static class

           A popup menu-specific 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.BaselineResizeBehavior, Component.BltBufferStrategy, 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
 
Constructor Summary

          Constructs a JPopupMenu without an "invoker".

          Constructs a JPopupMenu with the specified title.
 
Method Summary
 JMenuItem

          Appends a new menu item to the end of the menu which dispatches the specified Action object.
 JMenuItem
add(JMenuItem menuItem)

          Appends the specified menu item to the end of this menu.
 JMenuItem

          Creates a new menu item with the specified text and appends it to the end of this menu.
 void

          Adds a MenuKeyListener to the popup menu.
 void

          Adds a PopupMenu listener.
 void

          Appends a new separator at the end of the menu.
protected PropertyChangeListener

          Returns a properly configured PropertyChangeListener which updates the control as changes to the Action occur.
protected JMenuItem

          Factory method which creates the JMenuItem for Actions added to the JPopupMenu.
protected void

          Notifies PopupMenuListeners that this popup menu is cancelled.
protected void

          Notifies PopupMenuListeners that this popup menu will become invisible.
protected void

          Notifies PopupMenuListeners that this popup menu will become visible.
 AccessibleContext

          Gets the AccessibleContext associated with this JPopupMenu.
 Component

          Returns this JPopupMenu component.
 Component

          Returns the component at the specified index.
 int

          Returns the index of the specified component.
static boolean

          Gets the defaultLightWeightPopupEnabled property, which by default is true.
 Component

          Returns the component which is the 'invoker' of this popup menu.
 String

          Returns the popup menu's label
 Insets

          Returns the margin, in pixels, between the popup menu's border and its containees.
 MenuKeyListener[]

          Returns an array of all the MenuKeyListeners added to this JPopupMenu with addMenuKeyListener().
 PopupMenuListener[]

          Returns an array of all the PopupMenuListeners added to this JMenuItem with addPopupMenuListener().
 SingleSelectionModel

          Returns the model object that handles single selections.
 MenuElement[]

          Returns an array of MenuElements containing the submenu for this menu component.
 PopupMenuUI

          Returns the look and feel (L&F) object that renders this component.
 String

          Returns the name of the L&F class that renders this component.
 void
insert(Action a, int index)

          Inserts a menu item for the specified Action object at a given position.
 void
insert(Component component, int index)

          Inserts the specified component into the menu at a given position.
 boolean

          Checks whether the border should be painted.
 boolean

          Gets the lightWeightPopupEnabled property.
 boolean

          Returns true if the MouseEvent is considered a popup trigger by the JPopupMenu's currently installed UI.
 boolean

          Returns true if the popup menu is visible (currently being displayed).
 void
menuSelectionChanged(boolean isIncluded)

          Messaged when the menubar selection changes to activate or deactivate this menu.
 void

          Lays out the container so that it uses the minimum space needed to display its contents.
protected void

          Paints the popup menu's border if the borderPainted property is true.
protected String

          Returns a string representation of this JPopupMenu.
protected void

          Processes focus events occurring on this component by dispatching them to any registered FocusListener objects.
protected void

          Processes key stroke events such as mnemonics and accelerators.
 void

          Processes a key event forwarded from the MenuSelectionManager and changes the menu selection, if necessary, by using MenuSelectionManager's API.
 void

          This method is required to conform to the MenuElement interface, but it not implemented.
 void
remove(int pos)

          Removes the component at the specified index from this popup menu.
 void

          Removes a MenuKeyListener from the popup menu.
 void

          Removes a PopupMenu listener.
 void
setBorderPainted(boolean b)

          Sets whether the border should be painted.
static void

          Sets the default value of the lightWeightPopupEnabled property.
 void

          Sets the invoker of this popup menu -- the component in which the popup menu menu is to be displayed.
 void

          Sets the popup menu's label.
 void

          Sets the value of the lightWeightPopupEnabled property, which by default is true.
 void
setLocation(int x, int y)

          Sets the location of the upper left corner of the popup menu using x, y coordinates.
 void

          Sets the size of the Popup window using a Dimension object.
 void
setPopupSize(int width, int height)

          Sets the size of the Popup window to the specified width and height.
 void

          Sets the currently selected component, This will result in a change to the selection model.
 void

          Sets the model object to handle single selections.
 void

          Sets the L&F object that renders this component.
 void
setVisible(boolean b)

          Sets the visibility of the popup menu.
 void
show(Component invoker, int x, int y)

          Displays the popup menu at the position x,y in the coordinate space of the component invoker.
 void

          Resets the UI property to a value from the current look and feel.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, 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, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPopupMenu

public JPopupMenu()
Constructs a JPopupMenu without an "invoker".


JPopupMenu

public JPopupMenu(String label)
Constructs a JPopupMenu with the specified title.

Parameters:
label - the string that a UI may use to display as a title for the popup menu.
Method Detail

add

public JMenuItem add(Action a)
Appends a new menu item to the end of the menu which dispatches the specified Action object.

Parameters:
a - the Action to add to the menu
Returns:
the new menu item

add

public JMenuItem add(JMenuItem menuItem)
Appends the specified menu item to the end of this menu.

Parameters:
menuItem - the JMenuItem to add
Returns:
the JMenuItem added

add

public JMenuItem add(String s)
Creates a new menu item with the specified text and appends it to the end of this menu.

Parameters:
s - the string for the menu item to be added

addMenuKeyListener

public void addMenuKeyListener(MenuKeyListener l)
Adds a MenuKeyListener to the popup menu.

Parameters:
l - the MenuKeyListener to be added

addPopupMenuListener

public void addPopupMenuListener(PopupMenuListener l)
Adds a PopupMenu listener.

Parameters:
l - the PopupMenuListener to add

addSeparator

public void addSeparator()
Appends a new separator at the end of the menu.


createActionChangeListener

protected PropertyChangeListener createActionChangeListener(JMenuItem b)
Returns a properly configured PropertyChangeListener which updates the control as changes to the Action occur.

Parameters:
b

createActionComponent

protected JMenuItem createActionComponent(Action a)
Factory method which creates the JMenuItem for Actions added to the JPopupMenu.

Parameters:
a - the Action for the menu item to be added
Returns:
the new menu item

firePopupMenuCanceled

protected void firePopupMenuCanceled()
Notifies PopupMenuListeners that this popup menu is cancelled.


firePopupMenuWillBecomeInvisible

protected void firePopupMenuWillBecomeInvisible()
Notifies PopupMenuListeners that this popup menu will become invisible.


firePopupMenuWillBecomeVisible

protected void firePopupMenuWillBecomeVisible()
Notifies PopupMenuListeners that this popup menu will become visible.


getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JPopupMenu. For JPopupMenus, the AccessibleContext takes the form of an AccessibleJPopupMenu. A new AccessibleJPopupMenu instance is created if necessary.

Overrides:
getAccessibleContext in class JComponent
Returns:
an AccessibleJPopupMenu that serves as the AccessibleContext of this JPopupMenu

getComponent

public Component getComponent()
Returns this JPopupMenu component.

Returns:
this JPopupMenu object

getComponentAtIndex

public Component getComponentAtIndex(int i)
Returns the component at the specified index.

Parameters:
i - the index of the component, where 0 is the first
Returns:
the Component at that index

getComponentIndex

public int getComponentIndex(Component c)
Returns the index of the specified component.

Parameters:
c - the Component to find
Returns:
the index of the component, where 0 is the first; or -1 if the component is not found

getDefaultLightWeightPopupEnabled

public static boolean getDefaultLightWeightPopupEnabled()
Gets the defaultLightWeightPopupEnabled property, which by default is true.

Returns:
the value of the defaultLightWeightPopupEnabled property

getInvoker

public Component getInvoker()
Returns the component which is the 'invoker' of this popup menu.

Returns:
the Component in which the popup menu is displayed

getLabel

public String getLabel()
Returns the popup menu's label

Returns:
a string containing the popup menu's label

getMargin

public Insets getMargin()
Returns the margin, in pixels, between the popup menu's border and its containees.

Returns:
an Insets object containing the margin values.

getMenuKeyListeners

public MenuKeyListener[] getMenuKeyListeners()
Returns an array of all the MenuKeyListeners added to this JPopupMenu with addMenuKeyListener().

Returns:
all of the MenuKeyListeners added or an empty array if no listeners have been added

getPopupMenuListeners

public PopupMenuListener[] getPopupMenuListeners()
Returns an array of all the PopupMenuListeners added to this JMenuItem with addPopupMenuListener().

Returns:
all of the PopupMenuListeners added or an empty array if no listeners have been added

getSelectionModel

public SingleSelectionModel getSelectionModel()
Returns the model object that handles single selections.

Returns:
the selectionModel property

getSubElements

public MenuElement[] getSubElements()
Returns an array of MenuElements containing the submenu for this menu component. It will only return items conforming to the JMenuElement interface. If popup menu is null returns an empty array. This method is required to conform to the MenuElement interface.

Returns:
an array of MenuElement objects

getUI

public PopupMenuUI getUI()
Returns the look and feel (L&F) object that renders this component.

Returns:
the PopupMenuUI object that renders this component

getUIClassID

public String getUIClassID()
Returns the name of the L&F class that renders this component.

Overrides:
getUIClassID in class JComponent
Returns:
the string "PopupMenuUI"

insert

public void insert(Action a,
                   int index)
Inserts a menu item for the specified Action object at a given position.

Parameters:
a - the Action object to insert
index - specifies the position at which to insert the Action, where 0 is the first

insert

public void insert(Component component,
                   int index)
Inserts the specified component into the menu at a given position.

Parameters:
component - the Component to insert
index - specifies the position at which to insert the component, where 0 is the first

isBorderPainted

public boolean isBorderPainted()
Checks whether the border should be painted.

Returns:
true if the border is painted, false otherwise

isLightWeightPopupEnabled

public boolean isLightWeightPopupEnabled()
Gets the lightWeightPopupEnabled property.

Returns:
the value of the lightWeightPopupEnabled property

isPopupTrigger

public boolean isPopupTrigger(MouseEvent e)
Returns true if the MouseEvent is considered a popup trigger by the JPopupMenu's currently installed UI.

Parameters:
e
Returns:
true if the mouse event is a popup trigger

isVisible

public boolean isVisible()
Returns true if the popup menu is visible (currently being displayed).

Overrides:
isVisible in class Component

menuSelectionChanged

public void menuSelectionChanged(boolean isIncluded)
Messaged when the menubar selection changes to activate or deactivate this menu. This implements the javax.swing.MenuElement interface. Overrides MenuElement.menuSelectionChanged.

Parameters:
isIncluded - true if this menu is active, false if it is not

pack

public void pack()
Lays out the container so that it uses the minimum space needed to display its contents.


paintBorder

protected void paintBorder(Graphics g)
Paints the popup menu's border if the borderPainted property is true.

Overrides:
paintBorder in class JComponent
Parameters:
g - the Graphics object

paramString

protected String paramString()
Returns a string representation of this JPopupMenu. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overrides:
paramString in class JComponent
Returns:
a string representation of this JPopupMenu.

processFocusEvent

protected void processFocusEvent(FocusEvent evt)
Overrides:
processFocusEvent in class Component
Parameters:
evt

processKeyEvent

protected void processKeyEvent(KeyEvent evt)
Processes key stroke events such as mnemonics and accelerators.

Overrides:
processKeyEvent in class JComponent
Parameters:
evt - the key event to be processed

processKeyEvent

public void processKeyEvent(KeyEvent e,
                            MenuElement[] path,
                            MenuSelectionManager manager)
Processes a key event forwarded from the MenuSelectionManager and changes the menu selection, if necessary, by using MenuSelectionManager's API.

Note: you do not have to forward the event to sub-components. This is done automatically by the MenuSelectionManager.

Parameters:
e - a KeyEvent
path - the MenuElement path array
manager - the MenuSelectionManager

processMouseEvent

public void processMouseEvent(MouseEvent event,
                              MenuElement[] path,
                              MenuSelectionManager manager)
This method is required to conform to the MenuElement interface, but it not implemented.

Parameters:
event
path
manager

remove

public void remove(int pos)
Removes the component at the specified index from this popup menu.

Overrides:
remove in class Container
Parameters:
pos - the position of the item to be removed

removeMenuKeyListener

public void removeMenuKeyListener(MenuKeyListener l)
Removes a MenuKeyListener from the popup menu.

Parameters:
l - the MenuKeyListener to be removed

removePopupMenuListener

public void removePopupMenuListener(PopupMenuListener l)
Removes a PopupMenu listener.

Parameters:
l - the PopupMenuListener to remove

setBorderPainted

public void setBorderPainted(boolean b)
Sets whether the border should be painted.

Parameters:
b - if true, the border is painted.

setDefaultLightWeightPopupEnabled

public static void setDefaultLightWeightPopupEnabled(boolean aFlag)
Sets the default value of the lightWeightPopupEnabled property.

Parameters:
aFlag - true if popups can be lightweight, otherwise false

setInvoker

public void setInvoker(Component invoker)
Sets the invoker of this popup menu -- the component in which the popup menu menu is to be displayed.

Parameters:
invoker - the Component in which the popup menu is displayed

setLabel

public void setLabel(String label)
Sets the popup menu's label. Different look and feels may choose to display or not display this.

Parameters:
label - a string specifying the label for the popup menu

setLightWeightPopupEnabled

public void setLightWeightPopupEnabled(boolean aFlag)
Sets the value of the lightWeightPopupEnabled property, which by default is true. By default, when a look and feel displays a popup, it can choose to use a lightweight (all-Java) popup. Lightweight popup windows are more efficient than heavyweight (native peer) windows, but lightweight and heavyweight components do not mix well in a GUI. If your application mixes lightweight and heavyweight components, you should disable lightweight popups. Some look and feels might always use heavyweight popups, no matter what the value of this property.

Parameters:
aFlag - false to disable lightweight popups

setLocation

public void setLocation(int x,
                        int y)
Sets the location of the upper left corner of the popup menu using x, y coordinates.

Overrides:
setLocation in class Component
Parameters:
x - the x coordinate of the popup's new position in the screen's coordinate space
y - the y coordinate of the popup's new position in the screen's coordinate space

setPopupSize

public void setPopupSize(Dimension d)
Sets the size of the Popup window using a Dimension object. This is equivalent to setPreferredSize(d).

Parameters:
d - the Dimension specifying the new size of this component.

setPopupSize

public void setPopupSize(int width,
                         int height)
Sets the size of the Popup window to the specified width and height. This is equivalent to setPreferredSize(new Dimension(width, height)).

Parameters:
width - the new width of the Popup in pixels
height - the new height of the Popup in pixels

setSelected

public void setSelected(Component sel)
Sets the currently selected component, This will result in a change to the selection model.

Parameters:
sel - the Component to select

setSelectionModel

public void setSelectionModel(SingleSelectionModel model)
Sets the model object to handle single selections.

Parameters:
model - the new SingleSelectionModel

setUI

public void setUI(PopupMenuUI ui)
Sets the L&F object that renders this component.

Parameters:
ui - the new PopupMenuUI L&F object

setVisible

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

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

show

public void show(Component invoker,
                 int x,
                 int y)
Displays the popup menu at the position x,y in the coordinate space of the component invoker.

Parameters:
invoker - the component in whose space the popup menu is to appear
x - the x coordinate in invoker's coordinate space at which the popup menu is to be displayed
y - the y coordinate in invoker's coordinate space at which the popup menu is to be displayed

updateUI

public void updateUI()
Resets the UI property to a value from the current look and feel.

Overrides:
updateUI in class JComponent


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.