PopupFactory (Java 2 Platform SE 5.0) (original) (raw)
javax.swing
Class PopupFactory
java.lang.Object
javax.swing.PopupFactory
public class PopupFactory
extends Object
PopupFactory
, as the name implies, is used to obtain instances of Popup
s. Popup
s are used to display a Component
above all other Component
s in a particular containment hierarchy. The general contract is that once you have obtained a Popup
from aPopupFactory
, you must invoke hide
on thePopup
. The typical usage is:
PopupFactory factory = PopupFactory.getSharedInstance(); Popup popup = factory.getPopup(owner, contents, x, y); popup.show(); ... popup.hide();
Since:
1.4
See Also:
Constructor Summary |
---|
PopupFactory() |
Method Summary | |
---|---|
Popup | [getPopup](../../javax/swing/PopupFactory.html#getPopup%28java.awt.Component, java.awt.Component, int, int%29)(Component owner,Component contents, int x, int y) Creates a Popup for the Component owner containing the Component contents. |
static PopupFactory | getSharedInstance() Returns the shared PopupFactory which can be used to obtain Popups. |
static void | setSharedInstance(PopupFactory factory) Sets the PopupFactory that will be used to obtainPopups. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, [wait](../../java/lang/Object.html#wait%28long, int%29) |
Constructor Detail |
---|
PopupFactory
public PopupFactory()
Method Detail |
---|
setSharedInstance
public static void setSharedInstance(PopupFactory factory)
Sets the PopupFactory
that will be used to obtainPopup
s. This will throw an IllegalArgumentException
iffactory
is null.
Parameters:
factory
- Shared PopupFactory
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- if factory
is null
See Also:
[getPopup(java.awt.Component, java.awt.Component, int, int)](../../javax/swing/PopupFactory.html#getPopup%28java.awt.Component, java.awt.Component, int, int%29)
getSharedInstance
public static PopupFactory getSharedInstance()
Returns the shared PopupFactory
which can be used to obtain Popup
s.
Returns:
Shared PopupFactory
getPopup
public Popup getPopup(Component owner, Component contents, int x, int y) throws IllegalArgumentException
Creates a Popup
for the Component owner
containing the Component contents
. owner
is used to determine which Window
the newPopup
will parent the Component
thePopup
creates to. A null owner
implies there is no valid parent. x
andy
specify the preferred initial location to place the Popup
at. Based on screen size, or other paramaters, the Popup
may not display at x
andy
.
Parameters:
owner
- Component mouse coordinates are relative to, may be null
contents
- Contents of the Popup
x
- Initial x screen coordinate
y
- Initial y screen coordinate
Returns:
Popup containing Contents
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- if contents is null
Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.