JavaTM 2 Platform
Standard Ed. 6

javax.swing
类 PopupFactory

java.lang.Object
  继承者 javax.swing.PopupFactory

public class PopupFactory
extends Object

顾名思义,PopupFactory 用于获取 Popup 的实例。Popup 用于显示特定包含层次结构中所有其他 Component 之上的 Component。常规协定是从 PopupFactory 获取 Popup 之后,必须调用 Popup 上的 hide。一般用法为:

   PopupFactory factory = PopupFactory.getSharedInstance();
   Popup popup = factory.getPopup(owner, contents, x, y);
   popup.show();
   ...
   popup.hide();
 

从以下版本开始:
1.4
另请参见:
Popup

构造方法摘要
PopupFactory()
           
 
方法摘要
 Popup getPopup(Component owner, Component contents, int x, int y)
          为包含 Component contents 的 Component owner 创建 Popup
static PopupFactory getSharedInstance()
          返回共享 PopupFactory,它可用于获取 Popup
static void setSharedInstance(PopupFactory factory)
          设置用于获取 PopupPopupFactory
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

PopupFactory

public PopupFactory()
方法详细信息

setSharedInstance

public static void setSharedInstance(PopupFactory factory)
设置用于获取 PopupPopupFactory。如果 factory 为 null,这将抛出 IllegalArgumentException

参数:
factory - Shared PopupFactory
抛出:
IllegalArgumentException - 如果 factory 为 null
另请参见:
getPopup(java.awt.Component, java.awt.Component, int, int)

getSharedInstance

public static PopupFactory getSharedInstance()
返回共享 PopupFactory,它可用于获取 Popup

返回:
共享的 PopupFactory

getPopup

public Popup getPopup(Component owner,
                      Component contents,
                      int x,
                      int y)
               throws IllegalArgumentException
为包含 Component contents 的 Component owner 创建 Popupowner 用于确定 Window,新 Popup 将其作为创建 PopupComponent 的父级。null owner 暗示不存在有效的父级。xy 指定放置 Popup 的首选初始位置。基于屏幕大小或其他参数,Popup 不能显示在 xy 处。

参数:
owner - 组件鼠标坐标与其相关,它可以为 null
contents - Popup 的内容
x - 初始的 x 屏幕坐标
y - 初始的 y 屏幕坐标
返回:
包含 Contents 的 Popup
抛出:
IllegalArgumentException - 如果内容为 null

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only