event handler is a special user-defined
that can be added to a component when it is created
and that will be called automatically with a single
argument as the cursor moves over certain components.
The details, which are discussed below, depend on the type assigned
argument in the
event handler can only be added via
after a component is created,
but an existing
event handler can always be changed or temporarily disabled,
which is what happens when
is assigned to
The type that is assigned to the
argument in the declaration of
selects the events that
is declared to be a
will not arrive, if it is declared to be a
will not arrive, but if
can arrive and
to decide what to do.
behaves something like
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
should be used for.
when its declaration lets them through and the cursor moves over the component.
usually examines fields, like
argument and then returns a
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
is ignored and no changes are made, which is a little different than
when its declaration lets them through and the cursor moves over any component
that has accepted the data that this component's
stop arriving if the component that accepted the data decides to reject it.
may choose to change the
field in its
argument if a visual effect is called for,
but in this case nothing special is required and any return value from
will be ignored.
Some Swing components provide automatic drag and drop handling that
currently must be disabled by storing
field before your drag and drop event handlers will start working.
In other words, you probably should include a declaration that looks
whenever you build a Swing component provides its own drag and drop
Object transferhandler = NULL;
| See Also: