public class GhostedDragImage extends AbstractComponentDecorator
RootPaneContainer
in the current VM. Its location in
screen coordinates may be set via move(java.awt.Point)
.
When the image is no longer needed, invoke dispose()
, which
hides the graphic immediately, or returnToOrigin()
, which
moves the image to its original location prior to invoking
dispose()
.
AbstractComponentDecorator.Painter
DEFAULT_BOUNDS, TOP
Modifier | Constructor and Description |
---|---|
protected |
GhostedDragImage(JComponent dragSource,
JLayeredPane root,
Point screenLocation,
Icon icon,
Point imageOffset,
boolean trackFrames)
Create a ghosted drag image.
|
|
GhostedDragImage(JComponent dragSource,
Point screenLocation,
Icon icon,
Point imageOffset)
Create a ghosted drag image, using the given icon.
|
Modifier and Type | Method and Description |
---|---|
protected Rectangle |
clipDecorationBounds(Rectangle decorated)
Adjust the bounds of the painting component to allow some buffer
to avoid cursor flicker when moving.
|
void |
dispose()
Make all ghosted images go away.
|
void |
move(Point screen)
Move the ghosted image to the requested location.
|
void |
paint(Graphics graphics)
Paint the supplied image with transparency.
|
void |
returnToOrigin()
Animate the ghosted image returning to its origin.
|
void |
setAlpha(float alpha)
Set the transparency of the ghosted image.
|
void |
setCursor(Cursor cursor)
Ensure the decorator cursor matches the drag cursor, or we get
cursor flicker when autoscrolling.
|
attach, getComponent, getDecorationBounds, getPainter, getToolTipText, getToolTipText, isVisible, repaint, setDecorationBounds, setDecorationBounds, setPainterBounds, setToolTipText, setVisible, synch, toString
public GhostedDragImage(JComponent dragSource, Point screenLocation, Icon icon, Point imageOffset)
dragSource
- source of the dragscreenLocation
- screen location where the drag startedicon
- image to be drawnimageOffset
- offset of the image from the cursorprotected GhostedDragImage(JComponent dragSource, JLayeredPane root, Point screenLocation, Icon icon, Point imageOffset, boolean trackFrames)
dragSource
- source of the dragroot
- layered pane on which ghosted image is drawnscreenLocation
- initial location of image, in screen coordinatesicon
- icon to use for the ghost imageimageOffset
- offset of the image within the drag sourcetrackFrames
- if true, creates additional ghosts for all extant
frames which contain a JLayeredPane
where the image can be
painted.public void setAlpha(float alpha)
public void setCursor(Cursor cursor)
setCursor
in class AbstractComponentDecorator
public void dispose()
dispose
in class AbstractComponentDecorator
protected Rectangle clipDecorationBounds(Rectangle decorated)
clipDecorationBounds
in class AbstractComponentDecorator
public void move(Point screen)
screen
- Where to draw the image, in screen coordinatespublic void paint(Graphics graphics)
paint
in class AbstractComponentDecorator
public void returnToOrigin()
Copyright © 2023. All rights reserved.