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

For Java drag source, choosing an action other than the user action shows a no-drop cursor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 6
    • client-libs
    • generic
    • generic

      This bug affects a recent Swing DnD enhancement. Please fix it ASAP.

      - Please compile and run the attached demo.
      (NOTE: Requires Swing's b74 integration to run the attached test,
       but problem is unrelated to Swing changes)

      - On the left is a JList drag source with supported actions COPY and MOVE.
      - On the right are two JLists that both accept drops.
      - The top one chooses the MOVE action (through Swing with acceptDrag(MOVE))
      - The bottom one chooses the COPY action (through Swing with acceptDrag(COPY))
      - Drag from the source into the top list and it works
      - Drag from the source into the bottom list and it shows the NO-DROP cursor
        It still allows drops. But the wrong cursor is shown.
      - Drag text from a native text editor (that supports COPY and MOVE) and
        you'll see that the same problem doesn't exist.

      The problem is that Java is showing the NO-DROP drop cursor when you choose something other than the user drop action.
      This is wrong - you should be able to choose any of the supported source actions, like with a native drag source.

      I suspect the problem is the method DragSourceDragEvent.getDropAction(). Right now it does:

      return dropAction & targetActions & getDragSourceContext().getSourceActions();

      This is wrong, since it shouldn't intersect the user drop action (dropAction).

      Changing it to the following fixes the problem:

      return targetActions & getDragSourceContext().getSourceActions(); // note that targetActions is really just the single chosen target action

      -----------------------------

      The problem can also be reproduced in another way on Windows XP:

      - Launch SwingSet2.
      - Launch Microsoft's WordPad
      - Select "Enable Dragging" in the options menu
      - In the internal frames demo, select text and drag from the text field labeled "Frame title"
      - Drag into WordPad.
      - WordPad always selects the COPY option. Notice that this causes the NO_DROP cursor.
      - HOWEVER, even though the wrong cursor is shown, you can still drop.

            denis Denis Fokin (Inactive)
            shickeysunw Shannon Hickey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: