# Class DropTargetContext

java.lang.Object
java.awt.dnd.DropTargetContext

All Implemented Interfaces:
  `Serializable`

public final class DropTargetContext extends Object implements Serializable
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
See Also:
  - Serialized Form

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  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.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `acceptDrag(int dragOperation)`
  accept the Drag.
  `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.
  `protected Transferable`
  `createTransferableProxy(Transferable t, boolean local)`
  Creates a TransferableProxy to proxy for the specified Transferable.
  `void`
  `dropComplete(boolean success)`
  This method signals that the drop is completed and if it was successful or not.
  `Component`
  `getComponent()`
  This method returns the `Component` associated with this `DropTargetContext`.
  `protected DataFlavor[]`
  `getCurrentDataFlavors()`
  get the available DataFlavors of the `Transferable` operand of this operation.
  `protected List<DataFlavor>`
  `getCurrentDataFlavorsAsList()`
  This method returns the currently available DataFlavors of the `Transferable` operand as a `java.util.List`.
  `DropTarget`
  `getDropTarget()`
  This method returns the `DropTarget` associated with this `DropTargetContext`.
  `protected int`
  `getTargetActions()`
  This method returns an `int` representing the current actions this `DropTarget` will accept.
  `protected Transferable`
  `getTransferable()`
  get the Transferable (proxy) operand of this operation
  `protected boolean`
  `isDataFlavorSupported(DataFlavor 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. must be called during DropTargetListener.drop method invocation.
  `protected void`
  `setTargetActions(int actions)`
  This method sets the current actions acceptable to this `DropTarget`.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  Creates and returns a copy of this object.
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Method Details

  - ### getDropTarget

    public DropTarget getDropTarget()
    This method returns the `DropTarget` associated with this `DropTargetContext`.
    Returns:
      the `DropTarget` associated with this `DropTargetContext`

  - ### getComponent

    public Component getComponent()
    This method returns the `Component` associated with this `DropTargetContext`.
    Returns:
      the Component associated with this Context

  - ### setTargetActions

    protected void setTargetActions(int actions)
    This method sets the current actions acceptable to this `DropTarget`.
    Parameters:
      `actions` - an `int` representing the supported action(s)

  - ### getTargetActions

    protected int getTargetActions()
    This method returns an `int` representing the current actions this `DropTarget` will accept.
    Returns:
      the current actions acceptable to this `DropTarget`

  - ### dropComplete

    public void dropComplete(boolean success) throws InvalidDnDOperationException
    This method signals that the drop is completed and if it was successful or not.
    Parameters:
      `success` - true for success, false if not
    Throws:
      `InvalidDnDOperationException` - if a drop is not outstanding/extant

  - ### acceptDrag

    protected void acceptDrag(int dragOperation)
    accept the Drag.
    Parameters:
      `dragOperation` - the supported action(s)

  - ### rejectDrag

    protected void rejectDrag()
    reject the Drag.

  - ### acceptDrop

    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` - the supported action(s)

  - ### rejectDrop

    protected void rejectDrop()
    called to signal that the drop is unacceptable. must be called during DropTargetListener.drop method invocation.

  - ### getCurrentDataFlavors

    protected DataFlavor[] getCurrentDataFlavors()
    get the available DataFlavors of the `Transferable` operand of this operation.
    Returns:
      a `DataFlavor[]` containing the supported `DataFlavor`s of the `Transferable` operand.

  - ### getCurrentDataFlavorsAsList

    protected List<DataFlavor> getCurrentDataFlavorsAsList()
    This method returns the currently available DataFlavors of the `Transferable` operand as a `java.util.List`.
    Returns:
      the currently available DataFlavors as a `java.util.List`

  - ### isDataFlavorSupported

    protected boolean isDataFlavorSupported(DataFlavor df)
    This method returns a `boolean` indicating if the given `DataFlavor` is supported by this `DropTargetContext`.
    Parameters:
      `df` - the `DataFlavor` to test
    Returns:
      `true` if the `DataFlavor` specified is supported, otherwise `false`

  - ### getTransferable

    protected Transferable getTransferable() throws InvalidDnDOperationException
    get the Transferable (proxy) operand of this operation
    Returns:
      the `Transferable`
    Throws:
      `InvalidDnDOperationException` - if a drag is not outstanding/extant

  - ### createTransferableProxy

    protected Transferable createTransferableProxy(Transferable t, boolean local)
    Creates a TransferableProxy to proxy for the specified Transferable.
    Parameters:
      `t` - the `Transferable` to be proxied
      `local` - `true` if `t` represents the result of a local drag-n-drop operation.
    Returns:
      the new `TransferableProxy` instance.