Class ShadowPopupFactory
- java.lang.Object
-
- javax.swing.PopupFactory
-
- com.jgoodies.looks.common.ShadowPopupFactory
-
public final class ShadowPopupFactory extends javax.swing.PopupFactory
The JGoodies Looks implementation ofPopupFactory
. Adds a drop shadow border to all popups except ComboBox popups. It is installed by the JGoodies Plastic L&F during the Look&Feel initialization, seePlasticLookAndFeel.initialize()
.This factory shall not be used on platforms that provide native drop shadows, such as the Mac OS X. Therefore the invocation of the
install()
method will have no effect on such platforms.Note: To be used in a sandbox environment, this PopupFactory requires two AWT permissions:
createRobot
andreadDisplayPixels
. The reason for it is, that in the case of the heavy weight popups this PopupFactory uses a Robot to snapshot the screen background to simulate the drop shadow effect.- Version:
- $Revision: 1.8 $
- See Also:
AWTPermission
,Robot
,Popup
,LookAndFeel.initialize()
,LookAndFeel.uninitialize()
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.String
PROP_HORIZONTAL_BACKGROUND
In the case of heavy weight popups, snapshots of the screen background will be stored as client properties of the popup contents' parent.(package private) static java.lang.String
PROP_VERTICAL_BACKGROUND
private javax.swing.PopupFactory
storedFactory
The PopupFactory used before this PopupFactory has been installed in#install
.
-
Constructor Summary
Constructors Modifier Constructor Description private
ShadowPopupFactory(javax.swing.PopupFactory storedFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.swing.Popup
getPopup(java.awt.Component owner, java.awt.Component contents, int x, int y)
Creates aPopup
for the Componentowner
containing the Componentcontents
.static void
install()
Installs the ShadowPopupFactory as the shared popup factory on non-Mac platforms.static void
uninstall()
Uninstalls the ShadowPopupFactory and restores the original popup factory as the new shared popup factory.
-
-
-
Field Detail
-
PROP_HORIZONTAL_BACKGROUND
static final java.lang.String PROP_HORIZONTAL_BACKGROUND
In the case of heavy weight popups, snapshots of the screen background will be stored as client properties of the popup contents' parent. These snapshots will be used by the popup border to simulate the drop shadow effect. The two following constants define the names of these client properties.- See Also:
ShadowPopupBorder
, Constant Field Values
-
PROP_VERTICAL_BACKGROUND
static final java.lang.String PROP_VERTICAL_BACKGROUND
- See Also:
- Constant Field Values
-
storedFactory
private final javax.swing.PopupFactory storedFactory
The PopupFactory used before this PopupFactory has been installed in#install
. Used to restored the original state in#uninstall
.
-
-
Method Detail
-
install
public static void install()
Installs the ShadowPopupFactory as the shared popup factory on non-Mac platforms. Also stores the previously set factory, so that it can be restored in#uninstall
.In some Mac Java environments the popup factory throws a NullPointerException when we call
#getPopup
.TODO: The Mac case shows that we may have problems replacing non PopupFactory instances. Therefore we should consider replacing only instances of PopupFactory.
- See Also:
uninstall()
-
uninstall
public static void uninstall()
Uninstalls the ShadowPopupFactory and restores the original popup factory as the new shared popup factory.- See Also:
install()
-
getPopup
public javax.swing.Popup getPopup(java.awt.Component owner, java.awt.Component contents, int x, int y)
Creates aPopup
for the Componentowner
containing the Componentcontents
. In addition to the superclass behavior, we try to return a Popup that has a drop shadow, if popup drop shadows are active - as returned byOptions#isPopupDropShadowActive
.owner
is used to determine whichWindow
the newPopup
will parent theComponent
thePopup
creates to. A nullowner
implies there is no valid parent.x
andy
specify the preferred initial location to place thePopup
at. Based on screen size, or other paramaters, thePopup
may not display atx
andy
.We invoke the super
#getPopup
, not the one in the stored factory, because the popup type is set in this instance, not in the stored one.- Overrides:
getPopup
in classjavax.swing.PopupFactory
- 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:
java.lang.IllegalArgumentException
- if contents is null- See Also:
Options.isPopupDropShadowActive()
-
-