- java.lang.Object
-
- javax.swing.PopupFactory
-
public class PopupFactory extends Object
PopupFactory, as the name implies, is used to obtain instances ofPopups.Popups are used to display aComponentabove all otherComponents in a particular containment hierarchy. The general contract is that once you have obtained aPopupfrom aPopupFactory, you must invokehideon 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:
Popup
-
-
Constructor Summary
Constructors Constructor Description PopupFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PopupgetPopup(Component owner, Component contents, int x, int y)Creates aPopupfor the Componentownercontaining the Componentcontents.protected PopupgetPopup(Component owner, Component contents, int x, int y, boolean isHeavyWeightPopup)Creates aPopupfor the Componentownercontaining the Componentcontents.static PopupFactorygetSharedInstance()Returns the sharedPopupFactorywhich can be used to obtainPopups.static voidsetSharedInstance(PopupFactory factory)Sets thePopupFactorythat will be used to obtainPopups.
-
-
-
Method Detail
-
setSharedInstance
public static void setSharedInstance(PopupFactory factory)
Sets thePopupFactorythat will be used to obtainPopups. This will throw anIllegalArgumentExceptioniffactoryis null.- Parameters:
factory- Shared PopupFactory- Throws:
IllegalArgumentException- iffactoryis null- See Also:
getPopup(java.awt.Component, java.awt.Component, int, int)
-
getSharedInstance
public static PopupFactory getSharedInstance()
Returns the sharedPopupFactorywhich can be used to obtainPopups.- Returns:
- Shared PopupFactory
-
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 paramaters, 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
-
-