APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.awt.dnd

public final Class DropTargetContext

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.awt.Component, java.awt.datatransfer.DataFlavor, .Transferable, .UnsupportedFlavorException, java.awt.dnd.peer.DropTargetContextPeer, java.io.IOException, .Serial, .Serializable, java.util.Arrays, .List, sun.awt.AWTAccessor, .AWTAccessor.DropTargetContextAccessor

A DropTargetContext is created whenever the logical cursor associated with a Drag and Drop operation coincides with the visible geometry of a Component associated with a DropTarget. The DropTargetContext provides the mechanism for a potential receiver of a drop operation to both provide the end user with the appropriate drag under feedback, but also to effect the subsequent data transfer if appropriate.
Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
DropTargetContext.TransferableProxy

TransferableProxy is a helper inner class that implements Transferable interface and serves as a proxy for another Transferable object which represents data transfer for a particular drag-n-drop operation.

Field Summary

Modifier and TypeField and Description
private final DropTarget
dropTarget

The DropTarget associated with this DropTargetContext.

private transient DropTargetContextPeer
private static final long
serialVersionUID

Use serialVersionUID from JDK 1.4 for interoperability.

private transient Transferable

Constructor Summary

AccessConstructor and Description
pack-priv
DropTargetContext(DropTarget
the DropTarget to associate with
dt
)

Construct a DropTargetContext given a specified DropTarget.

Method Summary

Modifier and TypeMethod and Description
protected void
acceptDrag(int
the supported action(s)
dragOperation
)

accept the Drag.

protected void
acceptDrop(int
the supported action(s)
dropOperation
)

called to signal that the drop is acceptable using the specified operation.

protected Transferable

Returns:

the new TransferableProxy instance.
createTransferableProxy
(Transferable
the Transferable to be proxied
t
,
boolean
true if t represents the result of a local drag-n-drop operation.
local
)

Creates a TransferableProxy to proxy for the specified Transferable.

public void
dropComplete(boolean
true for success, false if not
success
)

This method signals that the drop is completed and if it was successful or not.

public Component

Returns:

the Component associated with this Context
getComponent
()

This method returns the Component associated with this DropTargetContext.

protected DataFlavor[]

Returns:

a DataFlavor[] containing the supported DataFlavors of the Transferable operand.
getCurrentDataFlavors
()

get the available DataFlavors of the Transferable operand of this operation.

protected List<DataFlavor>

Returns:

the currently available DataFlavors as a java.util.List
getCurrentDataFlavorsAsList
()

This method returns the currently available DataFlavors of the Transferable operand as a java.util.List.

public DropTarget

Returns:

the DropTarget associated with this DropTargetContext
getDropTarget
()

This method returns the DropTarget associated with this DropTargetContext.

pack-priv DropTargetContextPeer

Returns:

the platform peer
getDropTargetContextPeer
()

Get the DropTargetContextPeer

protected int

Returns:

the current actions acceptable to this DropTarget
getTargetActions
()

This method returns an int representing the current actions this DropTarget will accept.

protected Transferable

Returns:

the Transferable
getTransferable
()

get the Transferable (proxy) operand of this operation

protected boolean

Returns:

true if the DataFlavor specified is supported, otherwise false
isDataFlavorSupported
(DataFlavor
the DataFlavor to test
df
)

This method returns a boolean indicating if the given DataFlavor is supported by this DropTargetContext.

protected void
rejectDrag()

reject the Drag.

protected void
rejectDrop()

called to signal that the drop is unacceptable.

pack-priv void
reset()

Called when disassociated with the DropTargetContextPeer.

pack-priv void
setDropTargetContextPeer(final DropTargetContextPeer dtcp)

Sets the DropTargetContextPeer

protected void
setTargetActions(int
an int representing the supported action(s)
actions
)

This method sets the current actions acceptable to this DropTarget.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dropTargetback to summary
private final DropTarget dropTarget

The DropTarget associated with this DropTargetContext.

dropTargetContextPeerback to summary
private transient DropTargetContextPeer dropTargetContextPeer
serialVersionUIDback to summary
private static final long serialVersionUID

Use serialVersionUID from JDK 1.4 for interoperability.

Annotations
@Serial
transferableback to summary
private transient Transferable transferable

Constructor Detail

DropTargetContextback to summary
pack-priv DropTargetContext(DropTarget dt)

Construct a DropTargetContext given a specified DropTarget.

Parameters
dt:DropTarget

the DropTarget to associate with

Method Detail

acceptDragback to summary
protected void acceptDrag(int dragOperation)

accept the Drag.

Parameters
dragOperation:int

the supported action(s)

acceptDropback to summary
protected void acceptDrop(int dropOperation)

called to signal that the drop is acceptable using the specified operation. must be called during DropTargetListener.drop method invocation.

Parameters
dropOperation:int

the supported action(s)

createTransferableProxyback to summary
protected Transferable createTransferableProxy(Transferable t, boolean local)

Creates a TransferableProxy to proxy for the specified Transferable.

Parameters
t:Transferable

the Transferable to be proxied

local:boolean

true if t represents the result of a local drag-n-drop operation.

Returns:Transferable

the new TransferableProxy instance.

dropCompleteback to summary
public void dropComplete(boolean success) throws InvalidDnDOperationException

This method signals that the drop is completed and if it was successful or not.

Parameters
success:boolean

true for success, false if not

Exceptions
InvalidDnDOperationException:
if a drop is not outstanding/extant
getComponentback to summary
public Component getComponent()

This method returns the Component associated with this DropTargetContext.

Returns:Component

the Component associated with this Context

getCurrentDataFlavorsback to summary
protected DataFlavor[] getCurrentDataFlavors()

get the available DataFlavors of the Transferable operand of this operation.

Returns:DataFlavor[]

a DataFlavor[] containing the supported DataFlavors of the Transferable operand.

getCurrentDataFlavorsAsListback to summary
protected List<DataFlavor> getCurrentDataFlavorsAsList()

This method returns the currently available DataFlavors of the Transferable operand as a java.util.List.

Returns:List<DataFlavor>

the currently available DataFlavors as a java.util.List

getDropTargetback to summary
public DropTarget getDropTarget()

This method returns the DropTarget associated with this DropTargetContext.

Returns:DropTarget

the DropTarget associated with this DropTargetContext

getDropTargetContextPeerback to summary
pack-priv DropTargetContextPeer getDropTargetContextPeer()

Get the DropTargetContextPeer

Returns:DropTargetContextPeer

the platform peer

getTargetActionsback to summary
protected int getTargetActions()

This method returns an int representing the current actions this DropTarget will accept.

Returns:int

the current actions acceptable to this DropTarget

getTransferableback to summary
protected Transferable getTransferable() throws InvalidDnDOperationException

get the Transferable (proxy) operand of this operation

Returns:Transferable

the Transferable

Exceptions
InvalidDnDOperationException:
if a drag is not outstanding/extant
isDataFlavorSupportedback to summary
protected boolean isDataFlavorSupported(DataFlavor df)

This method returns a boolean indicating if the given DataFlavor is supported by this DropTargetContext.

Parameters
df:DataFlavor

the DataFlavor to test

Returns:boolean

true if the DataFlavor specified is supported, otherwise false

rejectDragback to summary
protected void rejectDrag()

reject the Drag.

rejectDropback to summary
protected void rejectDrop()

called to signal that the drop is unacceptable. must be called during DropTargetListener.drop method invocation.

resetback to summary
pack-priv void reset()

Called when disassociated with the DropTargetContextPeer.

setDropTargetContextPeerback to summary
pack-priv void setDropTargetContextPeer(final DropTargetContextPeer dtcp)

Sets the DropTargetContextPeer

setTargetActionsback to summary
protected void setTargetActions(int actions)

This method sets the current actions acceptable to this DropTarget.

Parameters
actions:int

an int representing the supported action(s)

java.awt.dnd back to summary

protected Class DropTargetContext.TransferableProxy

extends Object
implements Transferable
Class Inheritance
All Implemented Interfaces
java.awt.datatransfer.Transferable

TransferableProxy is a helper inner class that implements Transferable interface and serves as a proxy for another Transferable object which represents data transfer for a particular drag-n-drop operation.

The proxy forwards all requests to the encapsulated transferable and automatically performs additional conversion on the data returned by the encapsulated transferable in case of local transfer.

Field Summary

Modifier and TypeField and Description
protected boolean
isLocal

A boolean indicating if the encapsulated Transferable object represents the result of local drag-n-drop operation (within the same JVM).

private TransferableProxy
protected Transferable
transferable

The encapsulated Transferable object.

Constructor Summary

AccessConstructor and Description
pack-priv
TransferableProxy(Transferable
the Transferable object
t
,
boolean
true, if t represents the result of local drag-n-drop operation
local
)

Constructs a TransferableProxy given a specified Transferable object representing data transfer for a particular drag-n-drop operation and a boolean which indicates whether the drag-n-drop operation is local (within the same JVM).

Method Summary

Modifier and TypeMethod and Description
public Object
getTransferData(DataFlavor
the requested flavor for the data
df
)

Implements java.awt.datatransfer.Transferable.getTransferData.

Returns an object which represents the data provided by the encapsulated transferable for the requested data flavor.

public DataFlavor[]

Returns:

an array of data flavors in which the data can be provided by the encapsulated transferable
getTransferDataFlavors
()

Implements java.awt.datatransfer.Transferable.getTransferDataFlavors.

Returns an array of DataFlavor objects indicating the flavors the data can be provided in by the encapsulated transferable.

public boolean

Returns:

true if the data flavor is supported, false otherwise
isDataFlavorSupported
(DataFlavor
the requested flavor for the data
flavor
)

Implements java.awt.datatransfer.Transferable.isDataFlavorSupported.

Returns whether or not the specified data flavor is supported by the encapsulated transferable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

isLocalback to summary
protected boolean isLocal

A boolean indicating if the encapsulated Transferable object represents the result of local drag-n-drop operation (within the same JVM).

proxyback to summary
private TransferableProxy proxy
transferableback to summary
protected Transferable transferable

The encapsulated Transferable object.

Constructor Detail

TransferableProxyback to summary
pack-priv TransferableProxy(Transferable t, boolean local)

Constructs a TransferableProxy given a specified Transferable object representing data transfer for a particular drag-n-drop operation and a boolean which indicates whether the drag-n-drop operation is local (within the same JVM).

Parameters
t:Transferable

the Transferable object

local:boolean

true, if t represents the result of local drag-n-drop operation

Method Detail

getTransferDataback to summary
public Object getTransferData(DataFlavor df) throws UnsupportedFlavorException, IOException

Implements java.awt.datatransfer.Transferable.getTransferData.

Returns an object which represents the data provided by the encapsulated transferable for the requested data flavor.

In case of local transfer a serialized copy of the object returned by the encapsulated transferable is provided when the data is requested in application/x-java-serialized-object data flavor.

Parameters
df:DataFlavor

the requested flavor for the data

Exceptions
UnsupportedFlavorException:
if the requested data flavor is not supported.
IOException:
if the data is no longer available in the requested flavor.
getTransferDataFlavorsback to summary
public DataFlavor[] getTransferDataFlavors()

Implements java.awt.datatransfer.Transferable.getTransferDataFlavors.

Returns an array of DataFlavor objects indicating the flavors the data can be provided in by the encapsulated transferable.

Returns:DataFlavor[]

an array of data flavors in which the data can be provided by the encapsulated transferable

isDataFlavorSupportedback to summary
public boolean isDataFlavorSupported(DataFlavor flavor)

Implements java.awt.datatransfer.Transferable.isDataFlavorSupported.

Returns whether or not the specified data flavor is supported by the encapsulated transferable.

Parameters
flavor:DataFlavor

the requested flavor for the data

Returns:boolean

true if the data flavor is supported, false otherwise