Class Popup
- 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 Summary
Constructors Modifier Constructor and Description protected
Popup()
Creates aPopup
.protected
Popup(Component owner, Component contents, int x, int y)
Creates aPopup
for the Componentowner
containing the Componentcontents
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
hide()
Hides and disposes of thePopup
.void
show()
Makes thePopup
visible.
-
-
-
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 null -
contents
- Contents of the Popup -
x
- Initial x screen coordinate -
y
- 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.
-
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2022, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.