- java.lang.Object
-
- javax.swing.Popup
-
public class Popup extends Object
Popups are used to display aComponent
to the user, typically on top of all the otherComponent
s in a particular containment hierarchy.Popup
s have a very small life cycle. Once you have obtained aPopup
, and hidden it (invoked thehide
method), you should no longer invoke any methods on it. This allows thePopupFactory
to cachePopup
s for later use.The general contract is that if you need to change the size of the
Component
, or location of thePopup
, you should obtain a newPopup
.Popup
does not descend fromComponent
, rather implementations ofPopup
are responsible for creating and maintaining their ownComponent
s to render the requestedComponent
to the user.You typically do not explicitly create an instance of
Popup
, instead obtain one from aPopupFactory
.- Since:
- 1.4
- See Also:
PopupFactory
-
-
Constructor Detail
-
Popup
protected Popup(Component owner, Component contents, int x, int y)
Creates aPopup
for the Componentowner
containing the Componentcontents
.owner
is used to determine whichWindow
the newPopup
will parent theComponent
thePopup
creates to. A nullowner
implies there is no valid parent.x
andy
specify the preferred initial location to place thePopup
at. Based on screen size, or other paramaters, thePopup
may not display atx
andy
.- Parameters:
owner
- Component mouse coordinates are relative to, may be nullcontents
- Contents of the Popupx
- Initial x screen coordinatey
- Initial y screen coordinate- Throws:
IllegalArgumentException
- if contents is null
-
Popup
protected Popup()
Creates aPopup
. This is provided for subclasses.
-
-
Method Detail
-
show
public void show()
Makes thePopup
visible. If thePopup
is currently visible, this has no effect.
-
hide
public void hide()
Hides and disposes of thePopup
. Once aPopup
has been disposed you should no longer invoke methods on it. Adispose
dPopup
may be reclaimed and later used based on thePopupFactory
. As such, if you invoke methods on adisposed
Popup
, indeterminate behavior will result.
-
-