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.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
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