クラス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
- 関連項目:
-
コンストラクタのサマリー
コンストラクタ -
メソッドのサマリー
修飾子と型メソッド説明Componentcontentsを含むComponentownerのPopupを作成します。protected PopupComponentcontentsを含むComponentownerのPopupを作成します。static PopupFactoryPopupを取得するために使用できる共有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)がPopupの作成先のComponentの親となるかを指定するために使用します。ownerがnullの場合、有効な親がないことを示します。xとyには、Popupを最初に配置する位置を指定します。 画面サイズまたはその他のパラメータに基づいて、Popupがxおよびyに表示されない場合があります。- パラメータ:
owner- マウスの座標の基準になるComponent。nullも可contents- PopupのContentsx- 初期のx画面座標y- 初期のy画面座標- 戻り値:
- Contentsを含むPopup
- スロー:
IllegalArgumentException- contentsがnullの場合
-
getPopup
protected Popup getPopup(Component owner, Component contents, int x, int y, boolean isHeavyWeightPopup) throws IllegalArgumentException Componentcontentsを含むComponentownerのPopupを作成します。 コンポーネントownerを含むウィンドウが親ウィンドウとして使用されます。ownerがnullの場合、有効な親がないことを示します。xとyには、Popupを最初に配置する位置を指定します。 画面サイズまたはその他のパラメータに基づいて、Popupがxおよびyに表示されない場合があります。isHeavyWeightPopupは、Popupが重いかどうかを指定します。trueを渡すと、Popup型が強制的に重量になります。そうしないと、Popup型がPopupファクトリによって選択されます。 軽量Popupウィンドウは、重量の(ネイティブ・ピア)ウィンドウより効率的ですが、軽量コンポーネントと重量コンポーネントはGUIでよく混在しません。 このメソッドは、PopupFactoryサブクラスでのみ使用されます。- パラメータ:
owner- マウスの座標の基準になるComponent。nullも可contents- PopupのContentsx- 初期のx画面座標y- 初期のy画面座標isHeavyWeightPopup- ポップアップが重い場合はtrue、そうでない場合はポップアップ・ファクトリによってポップアップ・タイプが選択されます。- 戻り値:
- Contentsを含むPopup
- スロー:
IllegalArgumentException- contentsがnullの場合