|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JPopupMenu
An implementation of a Popup Menu -- a small window which 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 the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the JPopupMenu key assignments.
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. A future release of Swing will provide support for long term persistence.
Inner Class Summary | |
protected class |
JPopupMenu.AccessibleJPopupMenu
|
static class |
JPopupMenu.Separator
A popupmenu-specific separator. |
Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
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 | |
JPopupMenu()
Create a JPopupMenu without an "invoker". |
|
JPopupMenu(String label)
Create a JPopupMenu with the specified title. |
Method Summary | |
JMenuItem |
add(Action a)
Append a new menuitem 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 |
add(String s)
Creates a new menuitem with the specified text and appends it to the end of this menu. |
void |
addPopupMenuListener(PopupMenuListener l)
Add a PopupMenu listener param l the PopupMenuListener to add |
void |
addSeparator()
Appends a new separator at the end of the menu. |
protected PropertyChangeListener |
createActionChangeListener(JMenuItem b)
|
protected void |
firePopupMenuCanceled()
Notifies PopupMenuListeners that this popup menu is canceled |
protected void |
firePopupMenuWillBecomeInvisible()
Notifies PopupMenuListeners that this popup menu will become invisible |
protected void |
firePopupMenuWillBecomeVisible()
Notifies PopupMenuListeners that this popup menu will become visible |
AccessibleContext |
getAccessibleContext()
Get the AccessibleContext associated with this JComponent |
Component |
getComponent()
This method should return the java.awt.Component used to paint the receiving element. |
Component |
getComponentAtIndex(int i)
Returns the component at the specified index. |
int |
getComponentIndex(Component c)
Returns the index of the specified component. |
static boolean |
getDefaultLightWeightPopupEnabled()
Return the default value for the lightWeightPopupEnabled property. |
Component |
getInvoker()
Returns the component which is the 'invoker' of this popup menu. |
String |
getLabel()
Returns the popup menu's label |
Insets |
getMargin()
Returns the margin between the popupmenu's border and its containees. |
SingleSelectionModel |
getSelectionModel()
Returns the model object that handles single selections. |
MenuElement[] |
getSubElements()
This method should return an array containing the sub-elements for the receiving menu element |
PopupMenuUI |
getUI()
Returns the L&F object that renders this component. |
String |
getUIClassID()
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 |
isBorderPainted()
Checks whether the border should be painted. |
boolean |
isLightWeightPopupEnabled()
Returns true if lightweight (all-Java) popups are in use, or false if heavyweight (native peer) popups are being used. |
boolean |
isVisible()
Returns true if the popupmenu is visible (currently being displayed). |
void |
menuSelectionChanged(boolean isIncluded)
Call by the MenuSelection when the MenuElement is added or remove from the menu selection. |
void |
pack()
Layout the container so that it uses the minimum space needed to display its contents. |
protected void |
paintBorder(Graphics g)
Paint the popup menu's border if BorderPainted property is true. |
protected String |
paramString()
Returns a string representation of this JPopupMenu. |
void |
processKeyEvent(KeyEvent e,
MenuElement[] path,
MenuSelectionManager manager)
Process a key event. |
void |
processMouseEvent(MouseEvent event,
MenuElement[] path,
MenuSelectionManager manager)
Process a mouse event. |
void |
remove(Component comp)
Removes the specified component from this popup menu. |
void |
remove(int pos)
Removes the component at the specified index from this popup menu. |
void |
removePopupMenuListener(PopupMenuListener l)
Remove a PopupMenu listener param l the PopupMenuListener to remove |
void |
setBorderPainted(boolean b)
Sets whether the border should be painted. |
static void |
setDefaultLightWeightPopupEnabled(boolean aFlag)
Set the default value for the lightWeightPopupEnabled property. |
void |
setInvoker(Component invoker)
Sets the invoker of this popupmenu -- the component in which the popupmenu menu is to be displayed. |
void |
setLabel(String label)
Sets the popup menu's label. |
void |
setLightWeightPopupEnabled(boolean aFlag)
When displaying the popup, JPopupMenu choose to use a light weight popup if it fits. |
void |
setLocation(int x,
int y)
Set the location of the upper left corner of the popup menu using x, y coordinates. |
void |
setPopupSize(Dimension d)
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 |
setSelected(Component sel)
Sets the currently selected component, This will result in a change to the selection model. |
void |
setSelectionModel(SingleSelectionModel model)
Set the model object to handle single selections. |
void |
setUI(PopupMenuUI ui)
Sets the L&F object that renders this component. |
void |
setVisible(boolean b)
Set the visibility of the popup menu. |
void |
show(Component invoker,
int x,
int y)
Display the popupmenu at the position x,y in the coordinate space of the component invoker. |
void |
updateUI()
Notification from the UIFactory that the L&F has changed. |
Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
countComponents,
deliverEvent,
doLayout,
findComponentAt,
findComponentAt,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents,
getLayout,
insets,
invalidate,
isAncestorOf,
layout,
list,
list,
locate,
minimumSize,
paintComponents,
preferredSize,
print,
printComponents,
processContainerEvent,
processEvent,
removeAll,
removeContainerListener,
setCursor,
setLayout,
validate,
validateTree |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public JPopupMenu()
public JPopupMenu(String label)
label
- The string that a UI may use to display as a title
for the popup menu.Method Detail |
public static void setDefaultLightWeightPopupEnabled(boolean aFlag)
public static boolean getDefaultLightWeightPopupEnabled()
public PopupMenuUI getUI()
public void setUI(PopupMenuUI ui)
ui
- the new PopupMenuUI L&F objectUIDefaults.getUI(javax.swing.JComponent)
public void updateUI()
JComponent.updateUI()
public String getUIClassID()
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
public SingleSelectionModel getSelectionModel()
SingleSelectionModel
public void setSelectionModel(SingleSelectionModel model)
model
- the SingleSelectionModel to useSingleSelectionModel
public JMenuItem add(JMenuItem menuItem)
c
- the JMenuItem to addpublic JMenuItem add(String s)
s
- the string for the menuitem to be addedpublic JMenuItem add(Action a)
a
- the Action to add to the menuAction
public void remove(Component comp)
item
- the JMenuItem to be removed from the menupublic void remove(int pos)
index
- the position of the item to be removed.index
is less than 0.protected PropertyChangeListener createActionChangeListener(JMenuItem b)
public void setLightWeightPopupEnabled(boolean aFlag)
public boolean isLightWeightPopupEnabled()
public String getLabel()
setLabel(java.lang.String)
public void setLabel(String label)
label
- a String specifying the label for the popup menusetLabel(java.lang.String)
public void addSeparator()
public void insert(Action a, int index)
component
- the Action object to insertindex
- an int specifying the position at which
to insert the Action, where 0 is the firstAction
public void insert(Component component, int index)
component
- the Component to insertindex
- an int specifying the position at which
to insert the component, where 0 is the firstpublic void addPopupMenuListener(PopupMenuListener l)
public void removePopupMenuListener(PopupMenuListener l)
protected void firePopupMenuWillBecomeVisible()
protected void firePopupMenuWillBecomeInvisible()
protected void firePopupMenuCanceled()
public void pack()
public void setVisible(boolean b)
b
- true to make the popup visible, or false to
hide itpublic boolean isVisible()
true
if the component is visible;
false
otherwise.Component.setVisible(boolean)
public void setLocation(int x, int y)
x
- the x coordinate of the popup's new positiony
- the y coordinate of the popup's new positionpublic Component getInvoker()
public void setInvoker(Component invoker)
invoker
- the Component in which the popup menu is displayedpublic void show(Component invoker, int x, int y)
invoker
- The component in whose space the popupmenu is to appearx
- the x coordinate in invoker's coordinate space at which
the popup menu is to be displayedy
- the y coordinate in invoker's coordinate space at which
the popup menu is to be displayedpublic Component getComponentAtIndex(int i)
getComponent(int i)
instead.i
- the index of the component, where 0 is the firstpublic int getComponentIndex(Component c)
the
- Component to findpublic void setPopupSize(Dimension d)
d
- The dimension specifying the new size
of this component.public void setPopupSize(int width, int height)
width
- The new width of the Popup in pixels.height
- The new height of the Popup in pixels.public void setSelected(Component sel)
sel
- the Component to selectpublic boolean isBorderPainted()
setBorderPainted(boolean)
public void setBorderPainted(boolean b)
b
- if true, the border is painted.isBorderPainted()
protected void paintBorder(Graphics g)
public Insets getMargin()
protected String paramString()
null
.public AccessibleContext getAccessibleContext()
public void processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager)
public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager)
public void menuSelectionChanged(boolean isIncluded)
public MenuElement[] getSubElements()
public Component getComponent()
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |