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

Mac: DragAndDrop: Dragging files to the finder does not work


    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7u15, 8
    • Fix Version/s: 8
    • Component/s: javafx
    • Environment:

      Mac OS X 10.8.3, JavaFX 2.2.7-b01, JavaFX 8.0.0-ea-b82


      We want to drag a java.io.File from our JavaFX application to the Mac OS X finder or desktop. But no matter what we try the dragged File is not accepted (little stop sign on the dragged image).

      It works on Ubuntu and Windows XP.

      We put the Files into the ClipboardContent using clipboardContent.putFiles(). There is an example attached as well.

      If we output the ContentTypes of the Dragboard we get an additionally [placeholder.custom.bytes] entry:

      [[placeholder.custom.bytes], [application/x-java-file-list, java.file-list]]

      We wonder if this might be the cause that Mac OS X gets confused or something.

      SSCCE attached:

      import javafx.application.Application;
      import javafx.event.EventHandler;
      import javafx.geometry.Insets;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.input.ClipboardContent;
      import javafx.scene.input.DragEvent;
      import javafx.scene.input.Dragboard;
      import javafx.scene.input.MouseEvent;
      import javafx.scene.input.TransferMode;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      import java.io.File;
      import java.util.Arrays;

      public class Main extends Application {
          public static void main(String[] args) {

          public void start(final Stage stage) {
              final Button button = new Button("Drag me or drop files on me");
              button.setOnDragDetected(new EventHandler<MouseEvent>() {
                  public void handle(MouseEvent t) {

                      ClipboardContent clipboardContent = new ClipboardContent();
                      clipboardContent.putFiles(Arrays.asList(new File("/Users/jenshohmuth/Desktop/scenicView.properties"))); // FIXME YOU MIGHT WANNA CHANGE THAT FILE TO SOME OTHER EXISTING FILE

                      Dragboard dragboard = button.startDragAndDrop(TransferMode.COPY);
                      System.out.println("Transfer modes: " + dragboard.getTransferModes());


              button.setOnDragOver(new EventHandler<DragEvent>() {
                  public void handle(DragEvent t) {

              VBox group = new VBox();
              group.setPadding(new Insets(10));

              Scene scene = new Scene(group);




            • Assignee:
              pchelko Petr Pchelko (Inactive)
              jhohmuthjfx Jens Hohmuth (Inactive)
            • Votes:
              1 Vote for this issue
              4 Start watching this issue


              • Created: