- java.lang.Object
-
- javax.swing.PopupFactory
-
public class PopupFactory extends Object
PopupFactory,顾名思义,用来获得的实例Popup秒。Popups用于在特定包含层次结构中的所有其他Component上方显示Component。 一般的合同是,一旦你已经获得了Popup从PopupFactory,您必须调用hide在Popup。 典型用法是:PopupFactory factory = PopupFactory.getSharedInstance(); Popup popup = factory.getPopup(owner, contents, x, y); popup.show(); ... popup.hide();- 从以下版本开始:
- 1.4
- 另请参见:
-
Popup
-
-
构造方法摘要
构造方法 构造器 描述 PopupFactory()
-
方法摘要
所有方法 静态方法 实例方法 具体的方法 变量和类型 方法 描述 PopupgetPopup(Component owner, Component contents, int x, int y)为Componentowner创建一个Popup,其中包含Component目录。protected PopupgetPopup(Component owner, Component contents, int x, int y, boolean isHeavyWeightPopup)创建Popup为组件owner包含Component目录。static PopupFactorygetSharedInstance()返回共享PopupFactory,可用于获取Popups。static voidsetSharedInstance(PopupFactory factory)设置PopupFactory将被用于获取Popup秒。
-
-
-
方法详细信息
-
setSharedInstance
public static void setSharedInstance(PopupFactory factory)
设置PopupFactory将被用于获取Popup秒。 如果factory为null,这将抛出IllegalArgumentException。- 参数
-
factory- 共享PopupFactory - 异常
-
IllegalArgumentException- 如果factory为空 - 另请参见:
-
getPopup(java.awt.Component, java.awt.Component, int, int)
-
getSharedInstance
public static PopupFactory getSharedInstance()
返回共享PopupFactory,可用于获取Popups。- 结果
- 共享PopupFactory
-
getPopup
public Popup getPopup(Component owner, Component contents, int x, int y) throws IllegalArgumentException
创建Popup为组件owner包含Component目录。owner被用来确定哪个Window新Popup意愿父Component的Popup创建对。 nullowner表示没有有效的父级。x和y指定放置Popup的首选初始位置。 根据屏幕尺寸或其他参数,Popup可能不会显示在x和y。- 参数
-
owner- 组件鼠标坐标是相对的,可以为null -
目录- 弹出目录内容 -
x- 初始x屏幕坐标 -
y- 初始y屏幕坐标 - 结果
- 包含内容的弹出窗口
- 异常
-
IllegalArgumentException- 如果contents为null
-
getPopup
protected Popup getPopup(Component owner, Component contents, int x, int y, boolean isHeavyWeightPopup) throws IllegalArgumentException
创建Popup为组件owner包含Component目录。 包含组件owner的窗口将用作父窗口。 空owner表示没有有效的父级。x和y指定放置Popup的首选初始位置。 根据屏幕尺寸或其他参数,Popup可能不会显示在x和y。isHeavyWeightPopup指定Popup是否为重量级。 通过true将强制Popup类型为重量级,否则Popup类型将由Popup工厂选择。 轻量级Popup窗口比重量级(本机对等)窗口更有效,但轻量级和重量级组件在GUI中不能很好地混合。 此方法仅供PopupFactory子类使用。- 参数
-
owner- 组件鼠标坐标是相对的,可以为null -
目录- 弹出目录内容 -
x- 初始x屏幕坐标 -
y- 初始y屏幕坐标 -
isHeavyWeightPopup- 如果Popup应该是重量级,isHeavyWeightPopuptrue,否则弹出工厂将选择弹出窗口类型。 - 结果
- 包含内容的弹出窗口
- 异常
-
IllegalArgumentException- 如果contents为null
-
-