Package com.jgoodies.looks.common
Class ShadowPopup
java.lang.Object
javax.swing.Popup
com.jgoodies.looks.common.ShadowPopup
Does all the magic for getting popups with drop shadows.
It adds the drop shadow border to the Popup,
in
#show it snapshots the screen background as needed,
and in #hide it cleans up all changes made before.- Version:
- $Revision: 1.12 $
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static List<ShadowPopup>The cache to use for ShadowPopups.private static booleanIndicates whether we can make snapshots from screen or not.private ComponentThe contents of the popup.private ContainerThe heavy weight container of the popup contents, may be null.private static final intMax number of items to store in the cache.private BorderThe border of the contents' parent replaced by SHADOW_BORDER.private booleanThe old value of the opaque property of the contents' parent.private ComponentThe component mouse coordinates are relative to, may be null.private static final PointThe 'scratch pad' objects used to calculate dirty regions of the screen snapshots.private PopupThe real popup.private static final Rectangleprivate static final BorderThe singleton instance used to draw all borders.private static final intThe size of the drop shadow.private intThe desired x and y location of the popup.private intThe desired x and y location of the popup. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean(package private) static PopupgetInstance(Component owner, Component contents, int x, int y, Popup delegate) Returns a previously usedShadowPopup, or a new one if none of the popups have been recycled.private Containervoidhide()Hides and disposes of thePopup.private static voidrecycle(ShadowPopup popup) Recycles the ShadowPopup.private voidReinitializes this ShadowPopup using the given parameters.voidshow()Makes thePopupvisible.private voidsnapshot()Snapshots the background.
-
Field Details
-
MAX_CACHE_SIZE
private static final int MAX_CACHE_SIZEMax number of items to store in the cache.- See Also:
-
cache
The cache to use for ShadowPopups. -
SHADOW_BORDER
The singleton instance used to draw all borders. -
SHADOW_SIZE
private static final int SHADOW_SIZEThe size of the drop shadow.- See Also:
-
canSnapshot
private static boolean canSnapshotIndicates whether we can make snapshots from screen or not. -
owner
The component mouse coordinates are relative to, may be null. -
contents
The contents of the popup. -
x
private int xThe desired x and y location of the popup. -
y
private int yThe desired x and y location of the popup. -
popup
The real popup. The #show() and #hide() methods will delegate all calls to these popup. -
oldBorder
The border of the contents' parent replaced by SHADOW_BORDER. -
oldOpaque
private boolean oldOpaqueThe old value of the opaque property of the contents' parent. -
heavyWeightContainer
The heavy weight container of the popup contents, may be null. -
POINT
The 'scratch pad' objects used to calculate dirty regions of the screen snapshots.- See Also:
-
RECT
-
-
Constructor Details
-
ShadowPopup
public ShadowPopup()
-
-
Method Details
-
getInstance
Returns a previously usedShadowPopup, or a new one if none of the popups have been recycled. -
recycle
Recycles the ShadowPopup. -
canSnapshot
public static boolean canSnapshot() -
hide
public void hide()Hides and disposes of thePopup. Once aPopuphas been disposed you should no longer invoke methods on it. AdisposedPopupmay be reclaimed and later used based on thePopupFactory. As such, if you invoke methods on adisposedPopup, indeterminate behavior will result.In addition to the superclass behavior, we reset the stored horizontal and vertical drop shadows - if any.
-
show
public void show()Makes thePopupvisible. If the popup has a heavy-weight container, we try to snapshot the background. If thePopupis currently visible, it remains visible. -
reset
Reinitializes this ShadowPopup using the given parameters.- Parameters:
owner- component mouse coordinates are relative to, may be nullcontents- the contents of the popupx- the desired x location of the popupy- the desired y location of the popuppopup- the popup to wrap
-
snapshot
private void snapshot()Snapshots the background. The snapshots are stored as client properties of the contents' parent. The next time the border is drawn, this background will be used.Uses a robot on the default screen device to capture the screen region under the drop shadow. Does not use the window's device, because that may be an outdated device (due to popup reuse) and the robot's origin seems to be adjusted with the default screen device.
-
getLayeredPane
- Returns:
- the top level layered pane which contains the owner.
-