O'Reilly logo

JavaBeans Unleashed by Rick Leinecker, Dr. Donald Doherty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Droppable Component

For a GUI component to act as the destination of a drag-and-drop, it must be associated with two objects:

      java.awt.dnd.DropTarget
      java.awt.dnd.DropTargetListener

The DropTarget

The DropTarget's constructor makes associations with both the DropTarget and the DropTargetListener objects. Alternatively, the DropTarget has setComponent() and addDropTargetListener() methods. Newly defined java.awt.Component methods are used by the DropTarget's constructors to inform the Component that it is now associated with the DropTarget.

The following are the additions to java.awt.Component:

public void setDropTarget( DropTarget dt )
Public DropTarget getDropTarget()

Let's define a droppable component. After you create a DropTarget ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required