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

The DragGestureRecognizer

The user gesture or set of gestures initiating a drag-and-drop operation will vary per component, platform, and device. A DragGestureRecognizer protects you from platform dependencies by enclosing these implementation details. The instance method dragSource.createDefaultDragGestureRecognizer() obtains a recognizer and associates it with a component, action, and DragGestureListener. This example creates a subclass of a Swinglabel (JLabel). In its constructor, the necessary classes and associations are made for it to act as a drag source for either a copy or a move operation. Listeners will be discussed next. The code in Listing 12.1 represents the first steps in making any draggable component.

Listing 12.1 First Steps ...

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