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

Prasanta Sadhukhan psadhukhan at openjdk.org
Tue Jul 15 03:38:20 UTC 2025


> Issue is when `JFXPanel `is used to embed some JavaFX components and when we drag something from swing or an external application and try to drop on a JavaFX component inside the JFXPanel, it doesn't accept the drop showing "block" sign suggesting DnD is blocked. 
> 
> The problem is in both drag and drop side of operations where `acceptDrag `and `acceptDrop `on `DropTargetDragEvent `is not called because `DragEvent constructor` called from `Scene `
> [which is called from `SwingDnD `via `EmbeddedSceneDTInterface.handleDragEnter` and `handleDragDrop] 
> `
> is not storing `state.acceptedTransferMode` when eventType is not `DragEvent.DRAG_DROPPED` or `DragEvent.DRAG_DONE` but Scene creates DragEvent with only `DragEvent.ANY`
>  so `handleDragEnter `and `handleDragDrop `returns null as `DragEvent.getAcceptedTransferMode` returns null
> 
> Fix is made so that instead of relying on return value of handleDragEnter/handleDragDrop  which seems to be always null for reason mentioned above, we rely on `isDataFlavorSupported `check for the drag and drop as is being done in JDK side of DnD scheme.
> Also, to have a proper drop of the data, we get the focus owner from the JFXPanel scene and insert the text in the location pointed to by the mouse cursor.
> 
> Regression test is already present in tests/manual/swing/DragDropOntoJavaFXControlInJFXPanelTest.java

Prasanta Sadhukhan has updated the pull request incrementally with two additional commits since the last revision:

 - Revert module-info change
 - Update test with setOnDragOver and setOnDragDropped

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

Changes:
  - all: https://git.openjdk.org/jfx/pull/1843/files
  - new: https://git.openjdk.org/jfx/pull/1843/files/0f1c0491..fb145e9b

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jfx&pr=1843&range=02
 - incr: https://webrevs.openjdk.org/?repo=jfx&pr=1843&range=01-02

  Stats: 75 lines in 4 files changed: 28 ins; 38 del; 9 mod
  Patch: https://git.openjdk.org/jfx/pull/1843.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1843/head:pull/1843

PR: https://git.openjdk.org/jfx/pull/1843


More information about the openjfx-dev mailing list