|
|
||||||||||||||||||||||||||||||||||||||||||||||
Class DragHelperpublic abstract class DragHelper implements DragHandler { // Methods public void dragEnter(DragSession session); public void dragLeave(); public int dragOver(DragSession session, int x, int y); public void drop(DragSession session, int x, int y); protected abstract Object findDragObject(DragSession session, int x, int y); protected abstract DragHandler getDragHandler( DragSession session, Object object); protected void trackDragStatus(DragSession session, Object object, int effect); } This class provides a default implementation for a dragdrop protocol involving a set of objects that the system does not support. For instance, if you are designing a tree control that is not composed of system components, you could use this class (along with the DragProxy class) to help implement the enter, continue, leave, and drop behaviors over the subelements in your tree. Typically, you would extend the DragHelper class, providing hit-testing code to implement the findDragObject and getDragHandler methods. When a drag method is called on a class that extends DragHelper, the drag method calls the findDragObject method to hit-test the coordinates in the drag method. The derived class returns an Object that represents the hit result. If the Object has changed since the last hit-test, the drag helper then calls the getDragHandler method to obtain a DragHandler for the new hit Object. In addition, the derived class can override the trackDragStatus method to implement highlighting or some other form of feedback. MethodsdragEnterpublic void dragEnter(DragSession session); dragLeavepublic void dragLeave(); dragOverpublic int dragOver(DragSession session, int x, int y); droppublic void drop(DragSession session, int x, int y); findDragObjectprotected abstract Object findDragObject(DragSession session, int x, int y); getDragHandlerprotected abstract DragHandler getDragHandler(DragSession session, Object object); trackDragStatusprotected void trackDragStatus(DragSession session, Object object, int effect);
|