public class PopupMenu extends Menu
按照继承层次结构的意思, PopupMenu可以在任何地方使用Menu 。 但是,如果您使用PopupMenu像Menu (例如,您将其添加到MenuBar ),那么您不能在show上调用PopupMenu 。
| Modifier and Type | Class and Description |
|---|---|
protected class |
PopupMenu.AccessibleAWTPopupMenu
PopupMenu的内部类用于提供对辅助功能的默认支持。
|
Menu.AccessibleAWTMenuMenuItem.AccessibleAWTMenuItemMenuComponent.AccessibleAWTMenuComponent| Constructor and Description |
|---|
PopupMenu()
创建一个空名称的新的弹出菜单。
|
PopupMenu(String label)
创建一个具有指定名称的新弹出菜单。
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNotify()
创建弹出菜单的对等体。
|
AccessibleContext |
getAccessibleContext()
获取
AccessibleContext与此相关
PopupMenu 。
|
MenuContainer |
getParent()
返回此菜单组件的父容器。
|
void |
show(Component origin, int x, int y)
在相对于原始组件的x,y位置显示弹出式菜单。
|
add, add, addSeparator, countItems, getItem, getItemCount, insert, insert, insertSeparator, isTearOff, paramString, remove, remove, removeAll, removeNotifyaddActionListener, deleteShortcut, disable, disableEvents, enable, enable, enableEvents, getActionCommand, getActionListeners, getLabel, getListeners, getShortcut, isEnabled, processActionEvent, processEvent, removeActionListener, setActionCommand, setEnabled, setLabel, setShortcutdispatchEvent, getFont, getName, getPeer, getTreeLock, postEvent, setFont, setName, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetFont, postEventpublic PopupMenu()
throws HeadlessException
HeadlessException - 如果GraphicsEnvironment.isHeadless()返回true。
GraphicsEnvironment.isHeadless()
public PopupMenu(String label) throws HeadlessException
label - 非
null字符串,指定弹出菜单的标签
HeadlessException - 如果GraphicsEnvironment.isHeadless()返回true。
GraphicsEnvironment.isHeadless()
public MenuContainer getParent()
getParent在
MenuComponent
null如果此菜单组件是最外面的组件,则菜单栏本身
public void show(Component origin, int x, int y)
如果这个PopupMenu被用作Menu (即它有一个非Component父项),那么您不能在PopupMenu上调用此方法。
origin - 定义坐标空间的组件
x - 弹出菜单的x坐标位置
y - 弹出菜单的y坐标位置
NullPointerException - 如果父母是
null
IllegalArgumentException - 如果这个
PopupMenu有一个非
Component父
IllegalArgumentException - 如果原点不在父级的层次结构中
RuntimeException - 如果父母没有在屏幕上显示
public AccessibleContext getAccessibleContext()
AccessibleContext与此相关
PopupMenu 。
getAccessibleContext在界面
Accessible
getAccessibleContext在
Menu
AccessibleContext的这个
PopupMenu
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.