public final class ShadowPopup
extends javax.swing.Popup
#show it snapshots the screen background as needed,
and in #hide it cleans up all changes made before.ShadowPopupBorder,
ShadowPopupFactory| Modifier and Type | Field and Description |
|---|---|
private static java.util.List<ShadowPopup> |
cache
The cache to use for ShadowPopups.
|
private static boolean |
canSnapshot
Indicates whether we can make snapshots from screen or not.
|
private java.awt.Component |
contents
The contents of the popup.
|
private java.awt.Container |
heavyWeightContainer
The heavy weight container of the popup contents, may be null.
|
private static int |
MAX_CACHE_SIZE
Max number of items to store in the cache.
|
private javax.swing.border.Border |
oldBorder
The border of the contents' parent replaced by SHADOW_BORDER.
|
private boolean |
oldOpaque
The old value of the opaque property of the contents' parent.
|
private java.awt.Component |
owner
The component mouse coordinates are relative to, may be null.
|
private static java.awt.Point |
POINT
The 'scratch pad' objects used to calculate dirty regions of
the screen snapshots.
|
private javax.swing.Popup |
popup
The real popup.
|
private static java.awt.Rectangle |
RECT |
private static javax.swing.border.Border |
SHADOW_BORDER
The singleton instance used to draw all borders.
|
private static int |
SHADOW_SIZE
The size of the drop shadow.
|
private int |
x
The desired x and y location of the popup.
|
private int |
y
The desired x and y location of the popup.
|
| Constructor and Description |
|---|
ShadowPopup() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
canSnapshot() |
(package private) static javax.swing.Popup |
getInstance(java.awt.Component owner,
java.awt.Component contents,
int x,
int y,
javax.swing.Popup delegate)
Returns a previously used
ShadowPopup, or a new one
if none of the popups have been recycled. |
private java.awt.Container |
getLayeredPane() |
void |
hide()
Hides and disposes of the
Popup. |
private static void |
recycle(ShadowPopup popup)
Recycles the ShadowPopup.
|
private void |
reset(java.awt.Component owner,
java.awt.Component contents,
int x,
int y,
javax.swing.Popup popup)
Reinitializes this ShadowPopup using the given parameters.
|
void |
show()
Makes the
Popup visible. |
private void |
snapshot()
Snapshots the background.
|
private static final int MAX_CACHE_SIZE
private static java.util.List<ShadowPopup> cache
private static final javax.swing.border.Border SHADOW_BORDER
private static final int SHADOW_SIZE
private static boolean canSnapshot
private java.awt.Component owner
private java.awt.Component contents
private int x
private int y
private javax.swing.Popup popup
private javax.swing.border.Border oldBorder
private boolean oldOpaque
private java.awt.Container heavyWeightContainer
private static final java.awt.Point POINT
snapshot()private static final java.awt.Rectangle RECT
static javax.swing.Popup getInstance(java.awt.Component owner,
java.awt.Component contents,
int x,
int y,
javax.swing.Popup delegate)
ShadowPopup, or a new one
if none of the popups have been recycled.private static void recycle(ShadowPopup popup)
public static boolean canSnapshot()
public void hide()
Popup. Once a Popup
has been disposed you should no longer invoke methods on it. A
disposed Popup may be reclaimed and later used
based on the PopupFactory. As such, if you invoke methods
on a disposed Popup, indeterminate
behavior will result.In addition to the superclass behavior, we reset the stored horizontal and vertical drop shadows - if any.
hide in class javax.swing.Popuppublic void show()
Popup visible. If the popup has a
heavy-weight container, we try to snapshot the background.
If the Popup is currently visible, it remains visible.show in class javax.swing.Popupprivate void reset(java.awt.Component owner,
java.awt.Component contents,
int x,
int y,
javax.swing.Popup popup)
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 wrapprivate void snapshot()
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.
show(),
ShadowPopupBorder,
Robot.createScreenCapture(Rectangle)private java.awt.Container getLayeredPane()