The
drop
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
DropTargetEvent
argument whenever the user ends a drag and drop operation with a drop
over a component that previously, using
dragEnter,
dragOver,
or
dropActionChanged,
indicated its willingness to accept the data.
A
drop
event handler can only be added via
addEventHandler
after a component is created,
but an existing
drop
event handler can always be changed or temporarily disabled,
which is what happens when
NULL,
is assigned to
drop.
In most situations
drop
and
dragEnter
are the only two event handlers a component will implement when it
wants to accept data that is being transferred by a drag and drop
operation.
That data will be stored in the
transferrable
field of its
event
argument and
drop
can do whatever it wants with the data, but when it is done
it should return a
Number
that is non-zero to indicate success or zero to indicate failure.
The result will be recorded in the
succeeded
field of the
DragSourceEvent
that is passed to the
dragDropEnd
event handler, if there is one.
A return value that is the wrong type (e.g., a
String)
or missing will be recorded as a failure.
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: |
Number
or none
| | |
| See Also: |
actionPerformed,
addEventHandler,
adjustmentValueChanged,
caretUpdate,
componentHidden,
componentMoved,
componentResized,
componentShown,
dragDropEnd,
dragEnter,
dragExit,
DragGestureEvent,
dragGestureRecognized,
dragMouseMoved,
dragOver,
DragSourceEvent,
dropActionChanged,
DropTargetEvent,
focusGained,
focusLost,
hyperlinkActivated,
hyperlinkEntered,
hyperlinkExited,
invocationAction,
invocationBrowse,
invocationChange,
invocationEdit,
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
|
|