The
dragOver
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 as the cursor moves over certain components.
The details, which are discussed below, depend on the type assigned
to the
event
argument in the
dragOver
declaration.
A
dragOver
event handler can only be added via
addEventHandler
after a component is created,
but an existing
dragOver
event handler can always be changed or temporarily disabled,
which is what happens when
NULL,
is assigned to
dragOver.
The type that is assigned to the
event
argument in the declaration of
dragOver
selects the events that
dragOver
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
dragOver
should check
event,
usually using
instanceof,
to decide what to do.
dragOver
behaves something like
dragEnter,
but it is called whenever the cursor moves, so there is lots of overhead.
It can be used for fancy visual effects or to handle a complicated
drop target that needs to accept of reject data based on the cursor's
position, but other than that there is not much that
dragOver
should be used for.
dragOver
receives
DropTargetEvents
when its declaration lets them through and the cursor moves over the component.
dragOver
usually examines fields, like
dragowner,
location,
mimetypes,
and
transferable
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.
dragOver
receives
DragSourceEvents
when its declaration lets them through and the cursor moves over any component
that has accepted the data that this component's
dragGestureRecognized
exported.
DragSourceEvents
stop arriving if the component that accepted the data decides to reject it.
dragOver
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
dragOver
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,
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
|
|