javax.swing

Class JPopupMenu

Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, MenuElement, Serializable
Known Direct Subclasses:
BasicComboPopup

public class JPopupMenu
extends JComponent
implements Accessible, MenuElement

JPopupMenu is a container that is used to display popup menu's menu items. By default JPopupMenu is a lightweight container, however if it is the case that JPopupMenu's bounds are outside of main window, then heawyweight container will be used to display menu items. It is also possible to change JPopupMenu's default behavior and set JPopupMenu to always use heavyweight container. JPopupMenu can be displayed anywhere; it is a floating free popup menu. However before JPopupMenu is diplayed, its invoker property should be set. JPopupMenu's invoker is a component relative to which popup menu is displayed. JPopupMenu fires PopupMenuEvents to its registered listeners. Whenever JPopupMenu becomes visible on the screen then PopupMenuEvent indicating that popup menu became visible will be fired. In the case when JPopupMenu becomes invisible or cancelled without selection, then popupMenuBecomeInvisible() or popupMenuCancelled() methods of PopupMenuListeners will be invoked. JPopupMenu also fires PropertyChangeEvents when its bound properties change.In addittion to inheritted bound properties, JPopupMenu has 'visible' bound property. When JPopupMenu becomes visible/invisible on the screen it fires PropertyChangeEvents to its registered PropertyChangeListeners.
See Also:
Serialized Form

Nested Class Summary

protected class
JPopupMenu.AccessibleJPopupMenu
static class
JPopupMenu.Separator
This is the separator that can be used in popup menu.

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

protected SingleSelectionModel
selectionModel
SelectionModel that keeps track of menu selection.

Fields inherited from class javax.swing.JComponent

TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, accessibleContext, listenerList, ui

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

JPopupMenu()
Creates a new JPopupMenu object.
JPopupMenu(String label)
Creates a new JPopupMenu with specified label

Method Summary

JMenuItem
add(String text)
Constructs menu item with a specified label and adds it to popup menu
JMenuItem
add(Action action)
Constructs menu item associated with the specified action and adds it to the popup menu
JMenuItem
add(JMenuItem item)
Adds given menu item to the popup menu
void
addMenuKeyListener(MenuKeyListener l)
Adds a MenuKeyListener to the popup.
void
addPopupMenuListener(PopupMenuListener listener)
Adds popupMenuListener to listen for PopupMenuEvents fired by the JPopupMenu
void
addSeparator()
Adds separator to this popup menu
protected PropertyChangeListener
createActionChangeListener(JMenuItem item)
Creates PropertyChangeListener that listens to PropertyChangeEvents occuring in the Action associated with given menu item in this popup menu.
protected JMenuItem
createActionComponent(Action action)
Creates new menu item associated with a given action.
protected void
firePopupMenuCanceled()
This method calls popupMenuCanceled() of popup menu's PopupMenuListeners.
protected void
firePopupMenuWillBecomeInvisible()
This method calls popupMenuWillBecomeInvisible() of popup menu's PopupMenuListeners.
protected void
firePopupMenuWillBecomeVisible()
This method calls popupMenuWillBecomeVisible() of popup menu's PopupMenuListeners.
AccessibleContext
getAccessibleContext()
DOCUMENT ME!
Component
getComponent()
Method of the MenuElement interface.
Component
getComponentAtIndex(int index)
Deprecated. Replaced by getComponent(int)
int
getComponentIndex(Component component)
Returns index of the specified component in the popup menu
static boolean
getDefaultLightWeightPopupEnabled()
Returns flag indicating if newly created JPopupMenu will use heavyweight or lightweight container to display its menu items
Component
getInvoker()
Returns popup menu's invoker.
String
getLabel()
Returns label for this popup menu
Insets
getMargin()
Returns margin for this popup menu.
MenuKeyListener[]
getMenuKeyListeners()
Returns array of getMenuKeyListeners that are listening to JPopupMenu.
PopupMenuListener[]
getPopupMenuListeners()
Returns array of PopupMenuListeners that are listening to JPopupMenu
SingleSelectionModel
getSelectionModel()
Returns selectionModel used by this popup menu to keep track of the selection.
MenuElement[]
getSubElements()
Return subcomonents of this popup menu.
PopupMenuUI
getUI()
This method returns the UI used to display the JPopupMenu.
String
getUIClassID()
This method returns a name to identify which look and feel class will be the UI delegate for the menuItem.
void
insert(Component component, int index)
Insert given component to the popup menu at the specified index
void
insert(Action action, int index)
Create menu item associated with the given action and inserts it into the popup menu at the specified index
boolean
isBorderPainted()
Checks if this popup menu paints its border.
boolean
isLightWeightPopupEnabled()
Returns true if this popup menu will display its menu item in a lightweight container and false otherwise.
boolean
isPopupTrigger(MouseEvent event)
Checks if observing mouse event should trigger popup menu to show on the screen.
boolean
isVisible()
Return visibility of the popup menu
void
menuSelectionChanged(boolean changed)
Method of MenuElement Interface.
void
pack()
This methods sets popup menu's size to its' preferred size.
protected String
paramString()
A string that describes this JPopupMenu.
void
processKeyEvent(KeyEvent event, MenuElement[] path, MenuSelectionManager manager)
Process key events forwarded from MenuSelectionManager.
void
processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager)
Process mouse events forwarded from MenuSelectionManager.
void
remove(int index)
Revomes component at the given index from the menu.
void
removeMenuKeyListener(MenuKeyListener l)
Removes a MenuKeyListener from the popup.
void
removePopupMenuListener(PopupMenuListener listener)
Removes PopupMenuListener from JPopupMenu's list of listeners
void
setBorderPainted(boolean painted)
Sets if the border of the popup menu should be painter or not.
static void
setDefaultLightWeightPopupEnabled(boolean enabled)
Sets whether JPopupMenu should use ligthWeight container to display it menu items by default
void
setInvoker(Component component)
Sets popup menu's invoker.
void
setLabel(String label)
Sets label for this popup menu.
void
setLightWeightPopupEnabled(boolean enabled)
DOCUMENT ME!
void
setLocation(int x, int y)
Sets location of the popup menu.
void
setPopupSize(int width, int height)
Sets size of the popup menu
void
setPopupSize(Dimension size)
Sets size of the popup
void
setSelected(Component selected)
Selects specified component in this popup menu.
void
setSelectionModel(SingleSelectionModel model)
Sets selection model for this popup menu
void
setUI(PopupMenuUI ui)
Set the "UI" property of the menu item, which is a look and feel class responsible for handling popupMenu's input events and painting it.
void
setVisible(boolean visible)
Sets visibility property of this popup menu.
void
show(Component component, int x, int y)
This method displays JPopupMenu on the screen at the specified location.
void
updateUI()
This method sets this menuItem's UI to the UIManager's default for the current look and feel.

Methods inherited from class javax.swing.JComponent

addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, 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, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, 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, extends EventListener> T[] getListeners, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponentZOrder, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, 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, 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, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, 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, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, 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, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, 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, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, 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, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

selectionModel

protected SingleSelectionModel selectionModel
SelectionModel that keeps track of menu selection.

Constructor Details

JPopupMenu

public JPopupMenu()
Creates a new JPopupMenu object.

JPopupMenu

public JPopupMenu(String label)
Creates a new JPopupMenu with specified label
Parameters:
label - Label for popup menu.

Method Details

add

public JMenuItem add(String text)
Constructs menu item with a specified label and adds it to popup menu
Parameters:
text - label for the menu item to be added
Returns:
constructed menu item that was added to the popup menu

add

public JMenuItem add(Action action)
Constructs menu item associated with the specified action and adds it to the popup menu
Parameters:
action - Action for the new menu item
Returns:
menu item that was added to the menu

add

public JMenuItem add(JMenuItem item)
Adds given menu item to the popup menu
Parameters:
item - menu item to add to the popup menu
Returns:
menu item that was added to the popup menu

addMenuKeyListener

public void addMenuKeyListener(MenuKeyListener l)
Adds a MenuKeyListener to the popup.
Parameters:
l - - the listener to add.

addPopupMenuListener

public void addPopupMenuListener(PopupMenuListener listener)
Adds popupMenuListener to listen for PopupMenuEvents fired by the JPopupMenu
Parameters:
listener - PopupMenuListener to add to JPopupMenu

addSeparator

public void addSeparator()
Adds separator to this popup menu

createActionChangeListener

protected PropertyChangeListener createActionChangeListener(JMenuItem item)
Creates PropertyChangeListener that listens to PropertyChangeEvents occuring in the Action associated with given menu item in this popup menu.
Parameters:
item - MenuItem
Returns:
The PropertyChangeListener

createActionComponent

protected JMenuItem createActionComponent(Action action)
Creates new menu item associated with a given action.
Parameters:
action - Action used to create new menu item
Returns:
new created menu item associated with a given action.

firePopupMenuCanceled

protected void firePopupMenuCanceled()
This method calls popupMenuCanceled() of popup menu's PopupMenuListeners. This method is invoked just before popup menu is cancelled. This happens when popup menu is closed without selecting any of its menu items. This usually happens when the top-level window is resized or moved.

firePopupMenuWillBecomeInvisible

protected void firePopupMenuWillBecomeInvisible()
This method calls popupMenuWillBecomeInvisible() of popup menu's PopupMenuListeners. This method is invoked just before popup menu will disappear from the screen

firePopupMenuWillBecomeVisible

protected void firePopupMenuWillBecomeVisible()
This method calls popupMenuWillBecomeVisible() of popup menu's PopupMenuListeners. This method is invoked just before popup menu will appear on the screen.

getAccessibleContext

public AccessibleContext getAccessibleContext()
DOCUMENT ME!
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in interface JComponent
Returns:
DOCUMENT ME!

getComponent

public Component getComponent()
Method of the MenuElement interface. Returns reference to itself.
Specified by:
getComponent in interface MenuElement
Returns:
Returns reference to itself

getComponentAtIndex

public Component getComponentAtIndex(int index)

Deprecated. Replaced by getComponent(int)

Returns component located at the specified index in the popup menu
Parameters:
index - index of the component to return
Returns:
component located at the specified index in the popup menu

getComponentIndex

public int getComponentIndex(Component component)
Returns index of the specified component in the popup menu
Parameters:
component - Component to look for
Returns:
index of the specified component in the popup menu

getDefaultLightWeightPopupEnabled

public static boolean getDefaultLightWeightPopupEnabled()
Returns flag indicating if newly created JPopupMenu will use heavyweight or lightweight container to display its menu items
Returns:
true if JPopupMenu will use lightweight container to display menu items by default, and false otherwise.

getInvoker

public Component getInvoker()
Returns popup menu's invoker.
Returns:
popup menu's invoker

getLabel

public String getLabel()
Returns label for this popup menu
Returns:
label for this popup menu

getMargin

public Insets getMargin()
Returns margin for this popup menu.
Returns:
margin for this popup menu.

getMenuKeyListeners

public MenuKeyListener[] getMenuKeyListeners()
Returns array of getMenuKeyListeners that are listening to JPopupMenu.
Returns:
array of getMenuKeyListeners that are listening to JPopupMenu

getPopupMenuListeners

public PopupMenuListener[] getPopupMenuListeners()
Returns array of PopupMenuListeners that are listening to JPopupMenu
Returns:
Array of PopupMenuListeners that are listening to JPopupMenu

getSelectionModel

public SingleSelectionModel getSelectionModel()
Returns selectionModel used by this popup menu to keep track of the selection.
Returns:
popup menu's selection model

getSubElements

public MenuElement[] getSubElements()
Return subcomonents of this popup menu. This method returns only components that implement the MenuElement interface.
Specified by:
getSubElements in interface MenuElement
Returns:
array of menu items belonging to this popup menu

getUI

public PopupMenuUI getUI()
This method returns the UI used to display the JPopupMenu.
Returns:
The UI used to display the JPopupMenu.

getUIClassID

public String getUIClassID()
This method returns a name to identify which look and feel class will be the UI delegate for the menuItem.
Overrides:
getUIClassID in interface JComponent
Returns:
The Look and Feel classID. "PopupMenuUI"

insert

public void insert(Component component,
                   int index)
Insert given component to the popup menu at the specified index
Parameters:
component - Component to insert
index - Index at which to insert given component

insert

public void insert(Action action,
                   int index)
Create menu item associated with the given action and inserts it into the popup menu at the specified index
Parameters:
action - Action for the new menu item
index - index in the popup menu at which to insert new menu item.

isBorderPainted

public boolean isBorderPainted()
Checks if this popup menu paints its border.
Returns:
true if this popup menu paints its border and false otherwise.

isLightWeightPopupEnabled

public boolean isLightWeightPopupEnabled()
Returns true if this popup menu will display its menu item in a lightweight container and false otherwise.
Returns:
true if this popup menu will display its menu items in a lightweight container and false otherwise.

isPopupTrigger

public boolean isPopupTrigger(MouseEvent event)
Checks if observing mouse event should trigger popup menu to show on the screen.
Parameters:
event - MouseEvent to check
Returns:
true if the observing mouse event is popup trigger and false otherwise

isVisible

public boolean isVisible()
Return visibility of the popup menu
Overrides:
isVisible in interface Component
Returns:
true if popup menu is visible on the screen and false otherwise.

menuSelectionChanged

public void menuSelectionChanged(boolean changed)
Method of MenuElement Interface. It is invoked when popupMenu's selection has changed
Specified by:
menuSelectionChanged in interface MenuElement
Parameters:
changed - true if this popupMenu is part of current menu hierarchy and false otherwise.

pack

public void pack()
This methods sets popup menu's size to its' preferred size. If the popup menu's size is previously set it will be ignored.

paramString

protected String paramString()
A string that describes this JPopupMenu. Normally only used for debugging.
Overrides:
paramString in interface JComponent
Returns:
A string describing this JMenuItem

processKeyEvent

public void processKeyEvent(KeyEvent event,
                            MenuElement[] path,
                            MenuSelectionManager manager)
Process key events forwarded from MenuSelectionManager. This method doesn't do anything. It is here to conform to the MenuElement interface.
Specified by:
processKeyEvent in interface MenuElement
Parameters:
event - event forwarded from MenuSelectionManager
path - path to the menu element from which event was generated
manager - MenuSelectionManager for the current menu hierarchy

processMouseEvent

public void processMouseEvent(MouseEvent event,
                              MenuElement[] path,
                              MenuSelectionManager manager)
Process mouse events forwarded from MenuSelectionManager. This method doesn't do anything. It is here to conform to the MenuElement interface.
Specified by:
processMouseEvent in interface MenuElement
Parameters:
event - event forwarded from MenuSelectionManager
path - path to the menu element from which event was generated
manager - MenuSelectionManager for the current menu hierarchy

remove

public void remove(int index)
Revomes component at the given index from the menu.
Overrides:
remove in interface Container
Parameters:
index - index of the component that will be removed in the menu

removeMenuKeyListener

public void removeMenuKeyListener(MenuKeyListener l)
Removes a MenuKeyListener from the popup.
Parameters:
l - - the listener to remove.

removePopupMenuListener

public void removePopupMenuListener(PopupMenuListener listener)
Removes PopupMenuListener from JPopupMenu's list of listeners
Parameters:
listener - PopupMenuListener which needs to be removed

setBorderPainted

public void setBorderPainted(boolean painted)
Sets if the border of the popup menu should be painter or not.
Parameters:
painted - true if the border should be painted and false otherwise

setDefaultLightWeightPopupEnabled

public static void setDefaultLightWeightPopupEnabled(boolean enabled)
Sets whether JPopupMenu should use ligthWeight container to display it menu items by default
Parameters:
enabled - true if JPopupMenu should use lightweight container for displaying its menu items, and false otherwise.

setInvoker

public void setInvoker(Component component)
Sets popup menu's invoker.
Parameters:
component - The new invoker of this popup menu

setLabel

public void setLabel(String label)
Sets label for this popup menu. This method fires PropertyChangeEvent when the label property is changed. Please note that most of the Look & Feel will ignore this property.
Parameters:
label - label for this popup menu

setLightWeightPopupEnabled

public void setLightWeightPopupEnabled(boolean enabled)
DOCUMENT ME!
Parameters:
enabled - DOCUMENT ME!

setLocation

public void setLocation(int x,
                        int y)
Sets location of the popup menu.
Overrides:
setLocation in interface Component
Parameters:
x - X coordinate of the popup menu's location
y - Y coordinate of the popup menu's location

setPopupSize

public void setPopupSize(int width,
                         int height)
Sets size of the popup menu
Parameters:
width - width for the new size
height - height for the new size

setPopupSize

public void setPopupSize(Dimension size)
Sets size of the popup
Parameters:
size - Dimensions representing new size of the popup menu

setSelected

public void setSelected(Component selected)
Selects specified component in this popup menu.
Parameters:
selected - component to select

setSelectionModel

public void setSelectionModel(SingleSelectionModel model)
Sets selection model for this popup menu
Parameters:
model - new selection model of this popup menu

setUI

public void setUI(PopupMenuUI ui)
Set the "UI" property of the menu item, which is a look and feel class responsible for handling popupMenu's input events and painting it.
Parameters:
ui - The new "UI" property

setVisible

public void setVisible(boolean visible)
Sets visibility property of this popup menu. If the property is set to true then popup menu will be dispayed and popup menu will hide itself if visible property is set to false.
Overrides:
setVisible in interface JComponent
Parameters:
visible - true if popup menu will become visible and false otherwise.

show

public void show(Component component,
                 int x,
                 int y)
This method displays JPopupMenu on the screen at the specified location. Note that x and y coordinates given to this method should be expressed in terms of the popup menus' invoker.
Parameters:
component - Invoker for this popup menu
x - x-coordinate of the popup menu relative to the specified invoker
y - y-coordiate of the popup menu relative to the specified invoker

updateUI

public void updateUI()
This method sets this menuItem's UI to the UIManager's default for the current look and feel.
Overrides:
updateUI in interface JComponent

JPopupMenu.java -- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.