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)
          設置用於獲取 Popup 的 PopupFactory。
 
從類別 java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

建構子詳細資訊

PopupFactory

public PopupFactory()
方法詳細資訊

setSharedInstance

public static void setSharedInstance(PopupFactory factory)
設置用於獲取 Popup 的 PopupFactory。如果 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 創建 Popup。owner 用於確定 Window,新 Popup 將其作為創建 Popup 的 Component 的父級。null owner 暗示不存在有效的父級。x 和 y 指定放置 Popup 的首選初始位置。基於螢幕大小或其他參數,Popup 不能顯示在 x 和 y 處。

參數:
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。