RFR: 8141391: DnD doesn't work for JFXPanel [v2]

Kevin Rushforth kcr at openjdk.org
Mon Jul 14 21:00:45 UTC 2025


On Fri, 11 Jul 2025 23:23:22 GMT, Martin Fox <mfox at openjdk.org> wrote:

>> What code path does it take when pasting from an FX component?  Maybe we can look how it differs and try to redirect to that path, so the content gets pasted correctly.
>
> Am I missing something? I can't find any evidence that a JavaFX text input control processes drag-and-drop in any way or that it ever did (though I could only easily look back to jfx14). Did the manual test referenced here ever work?

@beldenfox No, you aren't missing something. The manual test program as written cannot work. There is no automatic drag-and-drop handling for JavaFX controls like TextField.

If I modify the test program to handle drag events in the target TextField, it works as expected. Here are the added lines needed to make it work. I'll attach the modified test program to the bug report.


                        textField.setOnDragOver(event -> {
                            if (event.getGestureSource() != textField &&
                                    event.getDragboard().hasString()) {
                                event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
                            }

                            event.consume();
                        });

                        textField.setOnDragDropped(event -> {
                            Dragboard db = event.getDragboard();
                            boolean success = false;
                            if (db.hasString()) {
                                textField.setText(db.getString());
                                success = true;
                            }
                            event.setDropCompleted(success);

                            event.consume();
                        });

                    }
                });

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1843#discussion_r2205809359


More information about the openjfx-dev mailing list