title: Drag and Drop event in Javafx 2.0
body: <p>i am working with javafx 2.0 and netbean 7.1, I am facing an problem when doing a drag and drop on a image over a ImageView, .i kept image as a source(one image) and 2 target point(2 box as target point).when trying to drag an image first time, its working fine and after sources image is entered in to target box.and again trying to drag the image, following error is trown "java.lang.IllegalArgumentException: Wrong byte buffer size 18x15 [1080] != 0" </p>
  
  <p>Once the image is moved to the destination object, i need to set the listener to change it as source, i feel that its throwing error in this place..</p>
  
  <p>code am using </p>
  
  <pre><code>public class DragandDropEx extends Application {
  
      /**
       * @param args the command line arguments
       */
      GridPane Board;
      ImageView deactivateImageView = new ImageView();
      ImageView newImageView = new ImageView();
  
  
  
  
      final Rectangle target = new Rectangle(0, 0, 50, 50);
      final Rectangle target2 = new Rectangle(0, 0, 50, 50);
  
  
      public static void main(String[] args) {
          launch(args);
      }
  
      @Override
      public void start(Stage primaryStage) {
          target.setFill(Color.CHOCOLATE);
          target2.setFill(Color.BLUE);
          Image image = new Image(getClass().getResourceAsStream("triangle.png"));
          getDeactivateImageView().setImage(image);
          Board = new GridPane();
          primaryStage.setTitle("Drag and Drop");
  
  
  
          createSource(getDeactivateImageView());
  
  
  
          target.setOnDragOver(new EventHandler&lt;DragEvent&gt;() {
  
              @Override
              public void handle(DragEvent events) {
                 events.acceptTransferModes(TransferMode.MOVE);
                 events.consume();
  
                     createTargetDrop(target,0,8);
              }
          });
          target2.setOnDragOver(new EventHandler&lt;DragEvent&gt;() {
  
              @Override
              public void handle(DragEvent events) {
                 events.acceptTransferModes(TransferMode.MOVE);
                  events.consume();
                  createTargetDrop(target2,0,9);
              }
          });
  
  
  
  
  
  
          Board.add(getDeactivateImageView(), 0, 1);
          Board.add(target, 0, 8);
          Board.add(target2, 0, 9);
  
          StackPane root = new StackPane();
          root.getChildren().add(Board);
          primaryStage.setScene(new Scene(root, 300, 250));
          primaryStage.show();
      }
  
      private void createSource(final ImageView imageView) {
         imageView.setOnDragDetected(new EventHandler&lt;MouseEvent&gt;() {
               @Override
              public void handle(MouseEvent events) {
                  Dragboard storeImage =imageView.startDragAndDrop(TransferMode.MOVE);
                  ClipboardContent content = new ClipboardContent();
                  content.putImage(imageView.getImage());
                  storeImage.setContent(content);                      **//  here i am getting error**
                  events.consume();
  
  
              }
          });
      }
  
      private void createTargetDrop(final Rectangle target,final int xCordination,final int yCordination) {
  
          target.setOnDragDropped(new EventHandler&lt;DragEvent&gt;() {
  
              @Override
              public void handle(DragEvent event) {
                  Dragboard db = event.getDragboard();
                  Image dragedImage = db.getImage();
                  getNewImageView().setImage(dragedImage);
                  getDeactivateImageView().setVisible(false);
                  setDeactivateImageView(getNewImageView());
                  Board.add(getDeactivateImageView(),xCordination,yCordination );
                  event.consume();
                  createSource(getDeactivateImageView());                                         // setting listener to new image
  
              }
          });
  
      }
  }
  </code></pre>