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 SummaryConstructors
- 
Method SummaryModifier 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- 
PopupFactorypublic PopupFactory()Constructs aPopupFactory.
 
- 
- 
Method Details
- 
getPopuppublic 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 null
- contents- Contents of the Popup
- x- Initial x screen coordinate
- y- Initial y screen coordinate
- Returns:
- Popup containing Contents
- Throws:
- IllegalArgumentException- if contents is null
 
- 
getPopupprotected 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 null
- contents- Contents of the Popup
- x- Initial x screen coordinate
- y- Initial y screen coordinate
- isHeavyWeightPopup- 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