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

Mac: DragEvent.getDragboard().getFiles() returns an empty list with FX 8

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • 8
    • 8
    • javafx
    • MacOS 10.8.2
      JDK 8 b65

      Attached code does:

              scene.addEventHandler(DragEvent.DRAG_ENTERED, new EventHandler<DragEvent>() {
                  @Override
                  public void handle(DragEvent dragEvent) {
                      Dragboard db = dragEvent.getDragboard();
                      final List<File> files = db.getFiles();
                      if (!files.isEmpty()) {
                          try {
                              final File file = files.get(0);
                              System.out.println("File: " + file.getAbsolutePath());
                              System.out.println("File exists: " + file.exists());
                          } catch (RuntimeException e) {}
                      } else {
                          System.out.println("Empty list of files !");
                      }
                      dragEvent.consume();
                  }
              });

      I start the program from a terminal, then I select in Finder a file and hover my FX scene to enter the event handler.
      When running it with Java 7 U10 (or Java 7 U12) I enter the if case, Dragboard.getFiles().get(0) returns the file name I used for hovering.
      When running it with Java 8 b65 I go to the else branch "Empty list of files !".
      Did I miss something ?

      I didn't give it a try on Windows nor Linux.

            anthony Anthony Petrov (Inactive)
            yjoan Yves Joan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: