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

Drag and Drop of files in a SwingNode fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u51
    • Fix Version/s: 10
    • Component/s: javafx
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_8

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.2.9200]

      A DESCRIPTION OF THE PROBLEM :
      When enabling drag n drop for a Swing component in a SwingNode and dropping a file from the explorer on it, it failes with an java.lang.IllegalArgumentException.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Start the application
      2. Drag n Drop a file from the explorer to the red panel


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should print the dataflavors on the console.
      ACTUAL -
      Crashes with exception.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: failed to parse:Shell IDList Array
      at java.awt.datatransfer.DataFlavor.<init>(DataFlavor.java:503)
      at javafx.embed.swing.DataFlavorUtils.getDataFlavors(DataFlavorUtils.java:64)
      at javafx.embed.swing.CachingTransferable.getTransferDataFlavors(CachingTransferable.java:62)
      at javafx.embed.swing.FXDnD$FXDropTargetContextPeer.getTransferDataFlavors(FXDnD.java:450)
      at java.awt.dnd.DropTargetContext.getCurrentDataFlavors(DropTargetContext.java:223)
      at java.awt.dnd.DropTargetDropEvent.getCurrentDataFlavors(DropTargetDropEvent.java:173)
      at dnd.explorer.Content$1.drop(Content.java:41)
      at java.awt.dnd.DropTarget.drop(DropTarget.java:455)
      at javafx.embed.swing.FXDnD$FXDropTargetContextPeer.lambda$postDropTargetEvent$11(FXDnD.java:498)
      at javafx.embed.swing.FXDnD$FXDropTargetContextPeer$$Lambda$148/1952674473.run(Unknown Source)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3.run(EventQueue.java:709)
      at java.awt.EventQueue$3.run(EventQueue.java:703)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Content
      {
         public static JPanel createPanel()
         {
            JPanel panel = new JPanel();
            panel.setSize(400, 400);
            panel.setBackground(Color.RED);

            panel.setDropTarget(new DropTarget(
                        panel, DnDConstants.ACTION_COPY, new DropTargetAdapter()
                  {
                     @Override
                     public void dragEnter(DropTargetDragEvent dtde)
                     {
                        dtde.acceptDrag(dtde.getDropAction());
                     }

                     @Override
                     public void drop(DropTargetDropEvent dtde)
                     {
                        for( DataFlavor dataFlavor : dtde.getCurrentDataFlavors() )
                        {
                           System.out.println(dataFlavor);
                        }
                     }
                  }
                  ));

            return panel;
         }
      }

      public class JavaFX extends Application
      {
         public static void main(String[] args)
         {
            Application.launch(JavaFX.class);
         }

         @Override
         public void start(Stage primaryStage) throws Exception
         {
            SwingNode swingNode = new SwingNode();
            VBox pane = new VBox(swingNode);
            SwingUtilities.invokeLater(
                  () -> {
                     swingNode.setContent(Content.createPanel());
                  }
            );

            primaryStage.setScene(new Scene(pane));

            primaryStage.setWidth(800);
            primaryStage.setHeight(600);
            primaryStage.show();
         }
      }
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            Assignee:
            psadhukhan Prasanta Sadhukhan
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: