- 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
-
-
构造方法摘要
构造方法 Constructor 描述 PopupFactory()
-
方法摘要
所有方法 静态方法 接口方法 具体的方法 Modifier and Type 方法 描述 PopupgetPopup(Component owner, Component contents, int x, int y)创建Popup为组件owner包含Componentcontents。protected PopupgetPopup(Component owner, Component contents, int x, int y, boolean isHeavyWeightPopup)创建Popup为组件owner包含Componentcontents。static PopupFactorygetSharedInstance()返回共享的PopupFactory,可用于获取Popups。static voidsetSharedInstance(PopupFactory factory)设置PopupFactory将被用于获取Popup秒。
-
-
-
方法详细信息
-
setSharedInstance
public static void setSharedInstance(PopupFactory factory)
设置PopupFactory将用于获取Popups。 如果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包含Componentcontents。owner被用来确定哪个Window新Popup意愿父Component的Popup创建对。 空值为owner意味着没有有效的父母。x和y指定了将Popup放置在的首选初始位置。 根据屏幕尺寸或其他参数,Popup可能不会显示在x和y。- 参数
-
owner- 组件鼠标坐标是相对的,可以是null -
contents- 弹出contents内容 -
x- 初始x屏幕坐标 -
y- 初始y屏幕坐标 - 结果
- 包含内容的弹出窗口
- 异常
-
IllegalArgumentException- 如果内容为空
-
getPopup
protected Popup getPopup(Component owner, Component contents, int x, int y, boolean isHeavyWeightPopup) throws IllegalArgumentException
创建Popup为组件owner包含Componentcontents。 包含组件owner的窗口将用作父窗口。 一个空的owner意味着没有有效的父。x和y指定了将Popup放置在的首选初始位置。 根据屏幕尺寸或其他参数,Popup可能不会显示在x和y。isHeavyWeightPopup指定Popup是否重量级。 通过true将强制Popup类型为重量级,否则Popup类型将由Popup工厂选定。 轻量级的Popup窗口比重量级(本机对等体)窗口更有效率,但轻量级和重量级组件在GUI中不能很好地混合。 此方法仅用于PopupFactory子类。- 参数
-
owner- 组件鼠标坐标是相对的,可以是null -
contents- 弹出contents内容 -
x- 初始x屏幕坐标 -
y- 初始y屏幕坐标 -
isHeavyWeightPopup- 如果弹出窗口应该是重量,isHeavyWeightPopuptrue,否则弹出窗口将被选择。 - 结果
- 包含内容的弹出窗口
- 异常
-
IllegalArgumentException- 如果内容为空
-
-