Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4091580

java.awt.dnd.DragSource.createDragSourceContext creates invalid DragSourceContex

XMLWordPrintable

    • 1.2beta4
    • sparc
    • solaris_2.5
    • Verified



      Name: sdC67446 Date: 11/10/97


      DragSource.createDragSourceContext(DragSourceContextPeer,Component,int actions,Image,Point,Transferable,DragSourceListener) doesn't set actions in returning DragSourceContext
      Here is the JDK Specification:
      --------------------------------------------------
       createDragSourceContext

       protected DragSourceContext createDragSourceContext(DragSourceContextPeer dscp,
                                                           Component c,
                                                           int actions,
                                                           Image dragImage,
                                                           Point imageOffset,
                                                           Transferable t,
                                                           DragSourceListener dsl)

            Create the DragSourceContext to handle this Drag. To incorporate a new
            DragSourceContext subclass, subclass DragSource and override this method.

      Here is the test demonstrating the bug:
      -----------------MyDragSource.java------------------------
      import java.awt.dnd.*;
      import java.awt.dnd.peer.*;
      import java.awt.*;
      import java.awt.datatransfer.Transferable;

      public class MyDragSource extends DragSource {

          public DragSourceContext createDragSourceContext(DragSourceContextPeer dscp,Component c, int actions,Image image,Point p, Transferable t, DragSourceListener dsl) {
              return super.createDragSourceContext(dscp,c,actions,image,p,t,dsl);
          };

          public static void main(String[] args) {

              DragSourceContextPeer dscp = new DragSourceContextPeer() {
                  int actions;
                  public void startDrag(DragSourceContext ds,AWTEvent trigger,int actions) {}
                  public Component getComponent() { return null; }
                  public boolean isDnDTrigger(AWTEvent awte) { return false; }
                  public void cancelDrag() {}
                  public void commitDrop() {}
                  public int getSourceActions() {return actions; }
                  public void setSourceActions(int a) { actions = a; }
                  public Cursor getCursor() { return null; }
                  public void setCursor(Cursor c) {}
                  public AWTEvent getTrigger() {return null;}
              };

              Component c = null;
              int actions = DnDConstants.ACTION_COPY;
              Image image = null;
              Point p = null;
              Transferable t = null;
              DragSourceListener dsl = null;

              MyDragSource ds = new MyDragSource();
              DragSourceContext dsc = ds.createDragSourceContext(dscp,c,actions,image,p,t,dsl);
              if (dsc.getSourceActions() != DnDConstants.ACTION_COPY)
                  System.out.println("Mistake.");
              System.exit(0);
          }
      }

      ---------Output from the test---------------------
      Mistake.
      --------------------------------------------------

      ======================================================================

            lcablesunw Larry Cable (Inactive)
            sdmitriesunw Sergei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: