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

Win: DnD deadlock when dragging from FX to JFXPanel

    Details

      Description

      Consider the following test case (source is below): two windows, one is a pure JavaFX window that acts as a drag source, another is a Swing window with FX embedded using JFXPanel that acts as a drop target. Dragging from FX to Swing 100% deadlocks in this scenario.

          public static void main(String[] args) {
              SwingUtilities.invokeLater(() -> {
                  JFrame f = new JFrame("F");
                  f.setBounds(400, 100, 320, 240);

                  JFXPanel p1 = new JFXPanel();
                  Platform.runLater(() -> {
                      Text t = new Text("Drag from here");
                      t.setStyle("-fx-font-size: 32px");
                      t.setOnDragDetected(new EventHandler<MouseEvent>() {
                          @Override
                          public void handle(MouseEvent event) {
                              Dragboard db = t.startDragAndDrop(TransferMode.COPY);
                              ClipboardContent content = new ClipboardContent();
                              content.putString("FX TEXT");
                              db.setContent(content);
                              event.consume();
                          }
                      });
                      t.setOnDragDone(new EventHandler<DragEvent>() {
                          @Override
                          public void handle(DragEvent event) {
                              t.setText("Drag done");
                          }
                      });
                      Scene s = new Scene(new FlowPane(t), Color.RED);
                      p1.setScene(s);
                  });
                  f.add(p1);
                  f.setVisible(true);

                  JFrame g = new JFrame("Swing");
                  g.setBounds(400, 500, 320, 240);
                  JFXPanel p2 = new JFXPanel();
                  Platform.runLater(() -> {
                      Text t = new Text("Drop here");
                      t.setStyle("-fx-font-size: 32px");
                      t.setOnDragEntered(new EventHandler<DragEvent>() {
                          @Override
                          public void handle(DragEvent event) {
                              event.acceptTransferModes(TransferMode.ANY);
                              event.consume();
                          }
                      });
                      t.setOnDragOver((event) -> {
                          event.acceptTransferModes(TransferMode.ANY);
                          event.consume();
                      });
                      t.setOnDragDropped(new EventHandler<DragEvent>() {
                          @Override
                          public void handle(DragEvent event) {
                              t.setText(event.getDragboard().getString());
                              event.setDropCompleted(true);
                              event.consume();
                          }
                      });
                      Scene s = new Scene(new FlowPane(t), Color.BLUE);
                      p2.setScene(s);
                  });
                  g.add(p2);
                  g.setVisible(true);
              });
          }

      Other 3 combinations (dragging from FX to FX, from JFXPanel to FX, and from JFXPanel to JFXPanel) work fine (the last is fixed in RT-28347).

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              art Artem Ananiev
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported: