The
dropActionChanged
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
or
DragSourceEvent
argument whenever the the drop action changes,
which can happen when the user changes the modifier keys that are held down.
The details, which are discussed below, depend on the type assigned
to the
event
argument in the
dropActionChanged
declaration.
A
dropActionChanged
event handler can only be added via
addEventHandler
after a component is created,
but an existing
dropActionChanged
event handler can always be changed or temporarily disabled,
which is what happens when
NULL,
is assigned to
dropActionChanged.
The type that is assigned to the
event
argument in the declaration of
dropActionChanged
selects the events that
dropActionChanged
receives.
If
event
is declared to be a
DropTargetEvent
then
DragSourceEvents
will not arrive, if it is declared to be a
DragSourceEvent
then
DropTargetEvents
will not arrive, but if
event
is an
Object
then
DropTargetEvents
and
DragSourceEvents
can arrive and
dropActionChanged
should check
event,
usually using
instanceof,
to decide what to do.
dropActionChanged
receives
DropTargetEvents
when its declaration lets them through and the drop action changes
while the cursor is over the component.
dropActionChanged
usually examines fields, like
action
in its
event
argument and then returns a
Number
that is non-zero if it accepts and zero if it rejects the data that
is being transferred by the drag and drop operation.
A return value that is missing or the wrong type (e.g., a
String)
is ignored and no changes are made, which is a little different than
dragEnter's
behavior.
dropActionChanged
receives
DragSourceEvents
when its declaration lets them through and the drop action changes
while this component's
dragGestureRecognized
is the one that exported the data to the drag and drop operation.
dropActionChanged
usually examines fields, like
action
in its
event
argument and may choose to change the
cursor
field in its
event
argument if a visual effect is called for,
but in this case nothing special is required and any return value from
dropActionChanged
will be ignored.
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,
drop,
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
|
|