Microsoft SDK for Java

WDragSession Class

The WDragSession Class of the com.ms.awt package 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.

public 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);
}

The WDragSession class is similar to the AFC-based implementation in the UIDragDrop class. The dragdrop APIs work for both AWT and Microsoft AFC, but are implemented slightly different. For information on implementing this functionality using AFC and a UIDragDrop object, see the Microsoft SDK for AFC.

The following example shows how you can implement drag-and-drop functionality using AWT and a WDragSession object:

Example

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;
    }
}

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.

Hierarchy

DragHelper 
  |
  +--WDragSession

© 1999 Microsoft Corporation. All rights reserved. Terms of use.