|
|
||||||||||||||||||||||||||||||||||||||||||
Class WDragSessionpublic class WDragSession extends DragHelper implements DragSession { // Methods public static void beginDrag(TransferSession session); public static void beginDrag(MetaObject data, int available); public static void beginDrag(MetaObject data, int available, int preferred); public static void beginDrag(DragSource source, MetaObject data, int available); public static void beginDrag(DragSource source, MetaObject data, int available, int preferred); public static void beginDrag(DragSource source, TransferSession session); } This class is an extension of the DragHelper class. It implements the drag-and-drop APIs presented in the com.ms.object and com.ms.object.dragdrop Java packages for AWT objects. The dragdrop APIs work for both AWT and Microsoft AFC, but are implemented slightly different. The following example shows how you can implement drag-and-drop functionality using AWT and a WDragSession object. import java.awt.*; import com.ms.object.*; import com.ms.object.dragdrop.*; import com.ms.awt.WDragSession; class DragMeAWT extends Canvas { //... public boolean mouseDown(Event e, int x, int y) { ObjectBag data = new ObjectBag(); data.addObject(null, null, Color.red); WDragSession.beginDrag(data, Transfer.COPY | Transfer.LINK); return true; } } The same functionality is achieved with the UIDragDrop class when you use AFC. import com.ms.ui.*; import com.ms.object.*; import com.ms.object.dragdrop.*; import java.awt.Color; class DragMeAFC extends UICanvas { //... public boolean mouseDown(Event e, int x, int y) { ObjectBag data = new ObjectBag(); data.addObject(null, null, Color.red); UIDragDrop.beginDrag(data, Transfer.COPY | Transfer.LINK); return true; } } Use the beginDrag methods to start a drag-and-drop operation. All beginDrag methods act on two parameters, a DragSource object, and a TransferSession. Several of the beginDrag methods accept various TransferSession constructor parameters to simplify drag session creation. DragHelper | +--WDragSession MethodsbeginDragpublic static void beginDrag(TransferSession session); beginDragpublic static void beginDrag(MetaObject data, int available); beginDragpublic static void beginDrag(MetaObject data, int available, int preferred); beginDragpublic static void beginDrag(DragSource source, MetaObject data, int available); beginDragpublic static void beginDrag(DragSource source, MetaObject data, int available, int preferred); beginDragpublic static void beginDrag(DragSource source, TransferSession session);
|