The
dragGestureRecognized
event handler is a special user-defined
Function
that can be added to a component when it is created
and that will be called automatically with a single
DragGestureEvent
argument whenever the user tries to start a drag and drop operation,
which usually happens when mouse button 1 is pressed over the
component and held down while the cursor is dragged a short distance.
A
dragGestureRecognized
event handler can only be added via
addEventHandler
after a component is created,
but an existing
dragGestureRecognized
event handler can always be changed or temporarily disabled,
which is what happens when
NULL,
is assigned to
dragGestureRecognized.
A component that wants to export data using its own drag and drop
event handlers needs a
dragGestureRecognized
event handler that returns an
Object
(other than
NULL)
that will be the data transferred by the drag and drop operation.
A return value that is
NULL
or missing means the drag and drop operation will not start.
dragGestureRecognized
can control other aspects of the drag and drop operation using fields,
like
anchor,
cursor,
offset,
padding,
and
visual,
that are defined in its
event
argument.
A drag and drop operation that started when
dragGestureRecognized
returned the data to be transferred ends when the user drops the data
by releasing the appropriate mouse button or cancels the operation by
hitting the
ESC
key, and at that point the component's
dragDropEnd
event handler, if there is one, will get a chance to clean up.
Some Swing components provide automatic drag and drop handling that
currently must be disabled by storing
NULL
in their
transferhandler
field before your drag and drop event handlers will start working.
In other words, you probably should include a declaration that looks
something like,
Object transferhandler = NULL;
whenever you build a Swing component provides its own drag and drop
event handlers.
| |
| Return: |
Object
| | |
| See Also: |
actionPerformed,
addEventHandler,
adjustmentValueChanged,
caretUpdate,
componentHidden,
componentMoved,
componentResized,
componentShown,
dragDropEnd,
dragEnter,
dragExit,
DragGestureEvent,
dragMouseMoved,
dragOver,
DragSourceEvent,
drop,
dropActionChanged,
DropTargetEvent,
focusGained,
focusLost,
hyperlinkActivated,
hyperlinkEntered,
hyperlinkExited,
invocationAction,
invocationBrowse,
invocationChange,
invocationEdit,
invocationEditImport,
invocationEditKey,
invocationRun,
invocationSelection,
itemStateChanged,
keyPressed,
keyReleased,
keyTyped,
mouseClicked,
mouseDragged,
mouseEntered,
mouseExited,
mouseMoved,
mousePressed,
mouseReleased,
mouseWheelMoved,
removeEventHandler,
stateChanged,
textValueChanged,
valueChanged,
windowActivated,
windowClosed,
windowClosing,
windowDeactivated,
windowDeiconified,
windowIconified,
windowOpened
|
|