How do i set a cell value in javafx tablecell after a drag and drop event is complete?
<p>I'm designing an application that allows a drag and drop on <code>TableView</code> cells.</p>

<p>However, once the drag and drop is complete and the values of the cells switched successfully, a double-click on the cells where drag and drop has been effected makes the cells change back to their original text before drag and drop.</p>

<p>Help me solve this issue. The following code is used to set <code>cellFactoryValue</code> for all the cells. I am new to javafx.</p>

<pre><code>private void setCellFactoryForColumns(TableColumn&lt;TimeTable, String&gt; col)
{
    col.setCellFactory((TableColumn&lt;TimeTable, String&gt; e) -&gt; {
        TableCell&lt;TimeTable, String&gt; cell = new TableCell&lt;TimeTable, String&gt;() {
            @Override
            public void updateItem(String item, boolean empty) {

                super.updateItem(item, empty);
                if (item == null || empty) {
                    setText(null);
                    setGraphic(null);
                } else {
                    setText(item);
                    setGraphic(null);
                }
            }
        };

        col.setOnEditCommit((CellEditEvent&lt;TimeTable, String&gt; t) -&gt; {
            ((TimeTable)t.getTableView().getItems().get(
                    t.getTablePosition().getRow())
                    ).setDay(t.getNewValue());
        });

        cell.setOnDragDetected((MouseEvent event) -&gt; {
            Dragboard db = cell.startDragAndDrop(TransferMode.ANY);

            ClipboardContent content = new ClipboardContent();
            content.putString(cell.getText());
            db.setContent(content);
            cell.setStyle("-fx-background-color: red;"
                        + "-fx-text-fill: white;");
            cell.startEdit();
            cell.setText("Dragged");

            event.consume();
        });

        cell.setOnDragOver((DragEvent event) -&gt;{
            if(event.getGestureSource() != cell &amp;&amp;
                    event.getDragboard().hasString())
            {
                event.acceptTransferModes(TransferMode.MOVE);
                cell.setStyle("-fx-background-color: green;"
                        + "-fx-text-fill: white;");
            }
            event.consume();
        });

        cell.setOnDragEntered((DragEvent event) -&gt;{
           if(event.getGestureSource() != cell &amp;&amp;
                   event.getDragboard().hasString()){
               cell.setStyle("-fx-background-color: yellow;");
           } 
           event.consume();
        });

        cell.setOnDragExited((DragEvent event) -&gt; {
           cell.setStyle("-fx-background-color: grey;");
           event.consume();
        });

        cell.setOnDragDropped((DragEvent event) -&gt; {
            Dragboard db = event.getDragboard();
            boolean success = false;
            if(db.hasString())
            {
                holdData = cell.getText();
                cell.setText(db.getString());
                success = true;
            }

            event.setDropCompleted(success);
            event.consume();
        });

        cell.setOnDragDone((DragEvent event) -&gt;{
           if(event.getTransferMode() == TransferMode.MOVE)
           {
               cell.setText(holdData);
           }
           event.consume();
        });
        return cell;
    });
}
</code></pre>