title: JavaFX Drag Drop Window Not Responding
body: <p>I am trying a simple Java FX program which creates a Window and all I need is to add the ability of reading a dropped file. I have got the following code snippet which doesn't throw any error but neither let me drop anything. When I try to drop a file, it shows a Red cursor(not allowed windows cursor)</p>
  
  <p>I am on Windows 8 machine and JDK Version 8.0_60. Not sure what the problem is. Is there something wrong with the code? Am I missing something?</p>
  
  <p>What I have tried - </p>
  
  <ol>
  <li>Tried changing the Transfer Mode</li>
  <li>Tried checking the file permissions</li>
  </ol>
  
  <p>Sorry, if there is a fooling mistake in the code as I am new to JavaFx.</p>
  
  <p>Here goes the code - </p>
  
  <pre><code>import javafx.application.Application;
  import javafx.event.EventHandler;
  import javafx.scene.Scene;
  import javafx.scene.control.Label;
  import javafx.scene.input.*;
  import javafx.scene.layout.StackPane;
  import javafx.scene.layout.VBox;
  import javafx.stage.Stage;
  
  public class DragMe extends Application {
  
      @Override
      public void start(Stage primaryStage) {
          Label label = new Label("Please Drag Your File Here.");
          Label dropped = new Label("");
          VBox dragTarget = new VBox();
          dragTarget.getChildren().addAll(label,dropped);
          dragTarget.setOnDragOver(new EventHandler&lt;DragEvent&gt;() {
  
              @Override
              public void handle(DragEvent event) {
                  if (event.getGestureSource() != dragTarget
                          &amp;&amp; event.getDragboard().hasString()) {
                      /* allow for both copying and moving, whatever user chooses */
                      event.acceptTransferModes(TransferMode.ANY);
                  }
                  event.consume();
              }
          });
  
          dragTarget.setOnDragDropped(new EventHandler&lt;DragEvent&gt;() {
  
              @Override
              public void handle(DragEvent event) {
                  Dragboard db = event.getDragboard();
                  boolean success = false;
                  if (db.hasString()) {
                      dropped.setText(db.getString());
                      success = true;
                  }
                  /* let the source know whether the string was successfully 
                   * transferred and used */
                  event.setDropCompleted(success);
  
                  event.consume();
              }
  
  
          });
  
          StackPane root = new StackPane();
          root.getChildren().add(dragTarget);
  
          Scene scene = new Scene(root, 500, 250);
  
          primaryStage.setTitle("Testing the Drap File");
          primaryStage.setScene(scene);
          primaryStage.show();
      }
  
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Had a discussion with NwDx and we tried to figure out the drag-drop in different scenarios.</p>
  
  <ol>
  <li>If the file is dragged from Eclipse File Tree, the dropping is allowed</li>
  <li>If the file is dragged from any other location e.g. Desktop, it doesn't work</li>
  <li>Tried creating a new Workspace for eclipse, but didn't work.</li>
  <li>Tried drag-drop in MS Word, and it works fine.</li>
  <li>Tried creating a JAR and running it, and it works fine.</li>
  </ol>
  
  <p>Tried starting Eclipse as Administrator but no luck. </p>
  
  <p><strong>SOLVED</strong></p>
  
  <p>Running Eclipse as Administrator causes this issue. Running normally works! Thanks NwDx for your code.
  (<a href="https://stackoverflow.com/questions/16124102/unable-to-drag-and-drop-to-eclipse">Unable to drag and drop to Eclipse</a>) </p>