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

Drag And Drop shows unexpected behavior under Linux

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P4
    • None
    • 1.2.2
    • client-libs
    • x86
    • linux

    Description



      Name: kaC94536 Date: 11/29/99



      The problem is - the object being draged can not be droped by releasing
      the mouse button. You can to drag an object but you can not drop it.
      Under Solaris the test works fine.

      I use jdk1.2.2-G under Linux.

      ----------------------------- test.java ------------------------

      import java.awt.*;
      import java.awt.datatransfer.*;
      import java.awt.dnd.*;

      public class test {

        public static void main(String args[]) {

          ScrollPane scrollPane = new ScrollPane();
          Frame testFrame = new Frame();
          Panel panel = new Panel();

          testFrame.setSize(640, 480);
          testFrame.setLayout(new BorderLayout());
          testFrame.setBackground(Color.lightGray);
          panel.setLayout(new BorderLayout());

          Label dropComponent = new Label("Drop here", Label.CENTER);
          dropComponent.setBackground(Color.green);
          panel.add(dropComponent, BorderLayout.WEST);
          
          Label dragComponent = new Label("Drag me");
          dragComponent.setBackground(Color.pink);
          panel.add(dragComponent, BorderLayout.EAST);
          
          DnDTest dnd = new DnDTest();
          new DropTarget(dropComponent, dnd);
          DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(dragComponent,
              DnDConstants.ACTION_COPY, dnd);

          scrollPane.add(panel);
          testFrame.add("Center", scrollPane);
          testFrame.setTitle("Ok");

          testFrame.setVisible(true);
        }
      }

      //==========================================================================//

      class ComponentTransferable implements Transferable {

          public DataFlavor[] getTransferDataFlavors() {
              try {
                  DataFlavor flavor = new DataFlavor(java.awt.Label.class, "Label");
                  DataFlavor df[] = {flavor};
                  return df;
            } catch (Exception e) {
                  return null;
            }
          }

          public boolean isDataFlavorSupported(DataFlavor flavor) {
              return true;
          }

          public Object getTransferData(DataFlavor flavor) {
              return null;
          }
      }

      //==========================================================================//

      class DnDTest implements DropTargetListener, DragGestureListener {

          public void dragEnter(DropTargetDragEvent dtde) {}
          public void dropActionChanged(DropTargetDragEvent e) {}

          public void dragOver(DropTargetDragEvent dtde) {}

          public void dragScroll(DropTargetDragEvent dtde) {}

          public void dragExit(DropTargetEvent dtde) {}

          public void drop(DropTargetDropEvent dtde) {
              dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
          }

          public void dragGestureRecognized(DragGestureEvent e) {
              e.startDrag(DragSource.DefaultCopyDrop, new ComponentTransferable(), new DSListener());
          }
      }

      //==========================================================================//

      class DSListener implements DragSourceListener {

        public void dragEnter(DragSourceDragEvent dsde) {}
        public void dragOver(DragSourceDragEvent dsde) {}
        public void dropActionChanged(DragSourceDragEvent dsde) {}
        public void dragExit(DragSourceEvent dse) {}
        public void dragDropEnd(DragSourceDropEvent dsde) {}
      }

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

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

      Attachments

        Activity

          People

            dmendenhsunw David Mendenhall (Inactive)
            kanisimosunw Konstantin Anisimov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: