Java Reference
In-Depth Information
Summary
Drag-and-drop support in Swing is rich and varied. You get quite a bit of behavior for free for
several of the standard components. If you need more, you can dig down a layer at a time until
you expose the features you need.
Typically, you don't need to dig all the way into java.awt.dnd classes like DragSourceDragEvent ,
DragSourceDropEvent , or DropTargetDragEvent (to name a few). They are there and doing their
work under the covers, but you don't need to worry about them. Instead, drag-and-drop support
is typically delegated to the TransferHandler associated with a property of the component to
drag. Just setDragEnabled(true) on that component, and you're ready to go. You can also set
up drag-and-drop support for other items, such as images, by creating an implementation of
the Transferable interface.
In the next chapter, you'll explore Swing's pluggable look and feel architecture. You'll
learn how to customize your user interfaces without changing the code for the program.
Search WWH ::




Custom Search