java.lang.Object
javax.swing.PopupFactory
PopupFactory 顾名思义,用于获取 Popup 的实例。 Popup s 用于在特定包含层次结构中显示 Component 高于所有其他 Component s。一般合同是,一旦您从 PopupFactory 获得了 Popup,您必须在 Popup 上调用 hide。典型用法是:
PopupFactory factory = PopupFactory.getSharedInstance(); Popup popup = factory.getPopup(owner, contents, x, y); popup.show(); ... popup.hide();
- 自从:
- 1.4
- 参见:
-
构造方法总结
构造方法 -
方法总结
修饰符和类型方法描述为包含组件contents的组件owner创建一个Popup。protected Popup为包含组件contents的组件owner创建一个Popup。static PopupFactory返回可用于获取Popup的共享PopupFactory。static voidsetSharedInstance(PopupFactory factory) 设置将用于获取Popup的PopupFactory。
-
构造方法详细信息
-
PopupFactory
public PopupFactory()构造一个PopupFactory
-
-
方法详情
-
getPopup
public Popup getPopup(Component owner, Component contents, int x, int y) throws IllegalArgumentException 为包含组件contents的组件owner创建一个Popup。owner用于确定哪个Window新的Popup将成为ComponentPopup创建的父级。 nullowner表示没有有效的父级。x和y指定放置Popup的首选初始位置。根据屏幕尺寸或其他参数,Popup可能不会显示在x和y上。- 参数:
owner- 组件鼠标坐标相对于,可能为空contents- 弹出窗口的内容x- 初始 x 屏幕坐标y- 初始 y 屏幕坐标- 返回:
- 包含内容的弹出窗口
- 抛出:
IllegalArgumentException- 如果内容为空
-
getPopup
protected Popup getPopup(Component owner, Component contents, int x, int y, boolean isHeavyWeightPopup) throws IllegalArgumentException 为包含组件contents的组件owner创建一个Popup。包含组件owner的窗口将用作父窗口。 nullowner表示没有有效的父级。x和y指定放置Popup的首选初始位置。根据屏幕尺寸或其他参数,Popup可能不会显示在x和y上。isHeavyWeightPopup指定Popup是否为重量级。传递true将强制Popup类型为重量级,否则Popup类型将由Popup工厂选择。轻量级Popup窗口比重量级(本机对等)窗口更有效,但轻量级和重量级组件在 GUI 中不能很好地混合。此方法仅供 PopupFactory 子类使用。- 参数:
owner- 组件鼠标坐标相对于,可能为空contents- 弹出窗口的内容x- 初始 x 屏幕坐标y- 初始 y 屏幕坐标isHeavyWeightPopup- 如果 Popup 应该是重量级的,则为真,否则弹出类型将由弹出工厂选择。- 返回:
- 包含内容的弹出窗口
- 抛出:
IllegalArgumentException- 如果内容为空