javax.swing
Class PopupFactory

java.lang.Object
  |
  +--javax.swing.PopupFactory

public class PopupFactory
extends Object

Unsafe: 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
Version:
1.15 04/11/02
See Also:
HeavyWeightPopup

Field Summary
(package private) static int HEAVY_WEIGHT_POPUP
           
(package private) static int LIGHT_WEIGHT_POPUP
          Key used to indicate a light weight popup should be used.
private static int MAX_CACHE_SIZE
          Max number of items to store in any one particular cache.
(package private) static int MEDIUM_WEIGHT_POPUP
          Key used to indicate a medium weight Popup should be used.
private  int popupType
          Default type of Popup to create.
private static Object SharedInstanceKey
          The shared instanceof PopupFactory is per AppContext.
 
Constructor Summary
PopupFactory()
          Suppressed:
 
Method Summary
private  Popup getHeadlessPopup(Component owner, Component contents, int ownerX, int ownerY)
          Creates a headless popup
private  Popup getHeavyWeightPopup(Component owner, Component contents, int ownerX, int ownerY)
          Creates a heavy weight popup.
private  Popup getLightWeightPopup(Component owner, Component contents, int ownerX, int ownerY)
          Creates a light weight popup.
private  Popup getMediumWeightPopup(Component owner, Component contents, int ownerX, int ownerY)
          Creates a medium weight popup.
 Popup getPopup(Component owner, Component contents, int x, int y)
          Suppressed: Creates a Popup for the Component owner containing the Component contents.
private  Popup getPopup(Component owner, Component contents, int ownerX, int ownerY, int popupType)
          Obtains the appropriate Popup based on popupType.
(package private)  int getPopupType()
          Returns the preferred type of Popup to create.
private  int getPopupType(Component owner, Component contents, int ownerX, int ownerY)
          Returns the popup type to use for the specified parameters.
static PopupFactory getSharedInstance()
          Suppressed: Returns the shared PopupFactory which can be used to obtain Popups.
private  boolean invokerInHeavyWeightPopup(Component i)
          Returns true if the Component i inside a heavy weight Popup.
(package private)  void setPopupType(int type)
          Provides a hint as to the type of Popup that should be created.
static void setSharedInstance(PopupFactory factory)
          Suppressed: Sets the AppContext specific PopupFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SharedInstanceKey

private static final Object SharedInstanceKey
The shared instanceof PopupFactory is per AppContext. This is the key used in the AppContext to locate the PopupFactory.


MAX_CACHE_SIZE

private static final int MAX_CACHE_SIZE
Max number of items to store in any one particular cache.


LIGHT_WEIGHT_POPUP

static final int LIGHT_WEIGHT_POPUP
Key used to indicate a light weight popup should be used.


MEDIUM_WEIGHT_POPUP

static final int MEDIUM_WEIGHT_POPUP
Key used to indicate a medium weight Popup should be used.


HEAVY_WEIGHT_POPUP

static final int HEAVY_WEIGHT_POPUP

popupType

private int popupType
Default type of Popup to create.

Constructor Detail

PopupFactory

public PopupFactory()
Suppressed:

Method Detail

setSharedInstance

public static void setSharedInstance(PopupFactory factory)
Suppressed: Sets the AppContext specific PopupFactory. This will throw an IllegalArgumentException if factory is null.

Parameters:
factory - Shared PopupFactory

getSharedInstance

public static PopupFactory getSharedInstance()
Suppressed: Returns the shared PopupFactory which can be used to obtain Popups.

Returns:
Shared PopupFactory

setPopupType

void setPopupType(int type)
Provides a hint as to the type of Popup that should be created.


getPopupType

int getPopupType()
Returns the preferred type of Popup to create.


getPopup

public Popup getPopup(Component owner,
                      Component contents,
                      int x,
                      int y)
               throws IllegalArgumentException
Suppressed: Creates a Popup for the Component owner containing the Component contents. owner is used to determine which Window the new Popup will parent the Component the Popup creates to. A null owner implies there is no valid parent. x and y specify the preferred initial location to place the Popup at. Based on screen size, or other paramaters, the Popup may not display at x and y.

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
IllegalArgumentException

getPopupType

private int getPopupType(Component owner,
                         Component contents,
                         int ownerX,
                         int ownerY)
Returns the popup type to use for the specified parameters.


getPopup

private Popup getPopup(Component owner,
                       Component contents,
                       int ownerX,
                       int ownerY,
                       int popupType)
Obtains the appropriate Popup based on popupType.


getHeadlessPopup

private Popup getHeadlessPopup(Component owner,
                               Component contents,
                               int ownerX,
                               int ownerY)
Creates a headless popup


getLightWeightPopup

private Popup getLightWeightPopup(Component owner,
                                  Component contents,
                                  int ownerX,
                                  int ownerY)
Creates a light weight popup.


getMediumWeightPopup

private Popup getMediumWeightPopup(Component owner,
                                   Component contents,
                                   int ownerX,
                                   int ownerY)
Creates a medium weight popup.


getHeavyWeightPopup

private Popup getHeavyWeightPopup(Component owner,
                                  Component contents,
                                  int ownerX,
                                  int ownerY)
Creates a heavy weight popup.


invokerInHeavyWeightPopup

private boolean invokerInHeavyWeightPopup(Component i)
Returns true if the Component i inside a heavy weight Popup.



comments?