title: Accessing properties of custom object from JavaFX DragAndDrop Clipboard
body: <p>How can I get my actual object out of the Dragboard with getContent()? Is there any possibility to specify the type? Todo and Doing are FlowPanes - MyRectangle is an exammple of a custom component.</p>
  
  <p>What I want to have: 
  Put an Object eg. an Rectangle with height, filled color etc. on the clipboard and get that object back from the board with height, color etc....</p>
  
  <pre><code>private static final DataFormat itemFormat = new DataFormat("custom.item");
  MyRectangle myRectangle = generateRectangle();
  
  myRectangle.setOnDragDetected(new EventHandler&lt;MouseEvent&gt;() {
  
      @Override
      public void handle(MouseEvent event) {
          Dragboard db = myRectangle
              .startDragAndDrop(TransferMode.MOVE);
  
          ClipboardContent content = new ClipboardContent();
          content.put(taskFormat, myRectangle);
  
          // Rectangle has height 
          System.out.println(myRectangle.getHeight());
          TaskItem task = new TaskItem();
          task.setTime(6);
          content.put(itemFormat, task);
          db.setContent(content);
  
          event.consume();
      }
      });
  
      myRectangle.setOnDragDone(new EventHandler&lt;DragEvent&gt;() {
      public void handle(DragEvent event) {
          event.consume();
      }
      });
  
  doing.setOnDragOver(new EventHandler&lt;DragEvent&gt;() {
      public void handle(DragEvent event) {
      if (event.getGestureSource() != doing) {
          event.acceptTransferModes(TransferMode.MOVE);
      }
  
      event.consume();
      }
  });
  
  doing.setOnDragEntered(new EventHandler&lt;DragEvent&gt;() {
      public void handle(DragEvent event) {
      event.consume();
      }
  });
  
  doing.setOnDragExited(new EventHandler&lt;DragEvent&gt;() {
      public void handle(DragEvent event) {
      event.consume();
      }
  });
  
  doing.setOnDragDropped(new EventHandler&lt;DragEvent&gt;() {
      public void handle(DragEvent event) {
      final Dragboard db = event.getDragboard();
      boolean success = false;
      if (db.hasContent(taskFormat)) {
          MyRectangle rect2 = (MyRectangle) db.getContent(taskFormat);
  
  
          System.out.println(rect2.getHeight());
          todo.getChildren().remove(rect2);
          doing.getChildren().add(rect2);
          success = true;
          // doing.getChildren().add(rectangle);
      }
      event.setDropCompleted(success);
      event.consume();
      }
  });
  
  private MyRectangle generateRectangle() {
  final MyRectangle rect2 = new MyRectangle(0, 0, 10, 10);
  rect2.setId("app");
  rect2.setArcHeight(8);
  rect2.setWidth(80);
  rect2.setArcWidth(8);
  rect2.setStrokeWidth(1);
  rect2.setStroke(Color.WHITE);
  rect2.setHeight(60);
  return rect2;
  }
  </code></pre>