Class PopupFactory
java.lang.Object
javax.swing.PopupFactory
PopupFactory, as the name implies, is used to obtain
instances of Popups. Popups are used to
display a Component above all other Components
in a particular containment hierarchy. The general contract is that
once you have obtained a Popup from a
PopupFactory, you must invoke hide on the
Popup. 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates aPopupfor the Componentownercontaining the Componentcontents.protected PopupCreates aPopupfor the Componentownercontaining the Componentcontents.static PopupFactoryReturns the sharedPopupFactorywhich can be used to obtainPopups.static voidsetSharedInstance(PopupFactory factory) Sets thePopupFactorythat will be used to obtainPopups.
-
Constructor Details
-
PopupFactory
public PopupFactory()Constructs aPopupFactory.
-
-
Method Details
-
getPopup
public Popup getPopup(Component owner, Component contents, int x, int y) throws IllegalArgumentException Creates aPopupfor the Componentownercontaining the Componentcontents.owneris used to determine whichWindowthe newPopupwill parent theComponentthePopupcreates to. A nullownerimplies there is no valid parent.xandyspecify the preferred initial location to place thePopupat. Based on screen size, or other parameters, thePopupmay not display atxandy.- Parameters:
owner- Component mouse coordinates are relative to, may be nullcontents- Contents of the Popupx- Initial x screen coordinatey- Initial y screen coordinate- Returns:
- Popup containing Contents
- Throws:
IllegalArgumentException- if contents is null
-
getPopup
protected Popup getPopup(Component owner, Component contents, int x, int y, boolean isHeavyWeightPopup) throws IllegalArgumentException Creates aPopupfor the Componentownercontaining the Componentcontents. The window containing the componentownerwill be used as the parent window. A nullownerimplies there is no valid parent.xandyspecify the preferred initial location to place thePopupat. Based on screen size, or other parameters, thePopupmay not display atxandy.isHeavyWeightPopupspecifies if thePopupwill be heavyweight. Passingtruewill force thePopuptype to be heavyweight, otherwisePopuptype will be selected byPopupfactory. LightweightPopupwindows are more efficient than heavyweight (native peer) windows, but lightweight and heavyweight components do not mix well in a GUI. This method is intended to be used only by PopupFactory sub-classes.- Parameters:
owner- Component mouse coordinates are relative to, may be nullcontents- Contents of the Popupx- Initial x screen coordinatey- Initial y screen coordinateisHeavyWeightPopup- true if Popup should be heavy weight, otherwise popup type will be selected by popup factory.- Returns:
- Popup containing Contents
- Throws:
IllegalArgumentException- if contents is null