-
Bug
-
Resolution: Fixed
-
P4
-
jfx17, jfx18, jfx19
-
b02
-
x86_64
-
linux
ADDITIONAL SYSTEM INFORMATION :
GNU/LINUX Fedora 34 (x86_64)
Kernel 5.14.9-200.fc34.x86_64
openjdk 17 2021-09-14
OpenJDK Runtime Environment 21.9 (build 17+35)
OpenJDK 64-Bit Server VM 21.9 (build 17+35, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
Using Fedora 34 (GNOME), dragging and dropping a file on a JavaFX GridPane will produce a NullPointerException:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot read field "dragboard" because "this.this$0.dndGesture" is null
at javafx.graphics/javafx.scene.Scene$DropTargetListener.drop(Scene.java:3004)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.lambda$handleDragDrop$2(GlassSceneDnDEventHandler.java:111)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.handleDragDrop(GlassSceneDnDEventHandler.java:107)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleDragDrop$11(GlassViewEventHandler.java:772)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleDragDrop(GlassViewEventHandler.java:771)
at javafx.graphics/com.sun.glass.ui.View.handleDragDrop(View.java:714)
at javafx.graphics/com.sun.glass.ui.View.notifyDragDrop(View.java:1043)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:290)
at java.base/java.lang.Thread.run(Thread.java:833)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Git clone this repository (branch feature/drag-and-drop):
https://github.com/CodeDead/opal/tree/feature/drag-and-drop
Run the application, and drag and drop a file on the main window, and regardless of what you do, you will always get the following exception:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot read field "dragboard" because "this.this$0.dndGesture" is null
Problematic code in question:
/**
* Method that is invoked when a drag-over event is occurring
*
* @param dragEvent The {@link DragEvent} object
*/
@FXML
private void onDragOver(final DragEvent dragEvent) {
if (dragEvent.getGestureSource() != scpMain && dragEvent.getDragboard().hasFiles()) {
dragEvent.acceptTransferModes(TransferMode.COPY_OR_MOVE);
}
dragEvent.consume();
}
/**
* Method that is invoked when a drag-drop event occurred
*
* @param dragEvent The {@link DragEvent} object
*/
@FXML
public void onDragDropped(final DragEvent dragEvent) {
final Dragboard db = dragEvent.getDragboard();
boolean success = false;
if (db.hasFiles()) {
success = true;
}
dragEvent.setDropCompleted(success);
dragEvent.consume();
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The exception should not happen
ACTUAL -
The NullPointerException happens every single time you drag and drop a file
---------- BEGIN SOURCE ----------
Code available on GitHub:
https://github.com/CodeDead/opal/tree/feature/drag-and-drop
Please make sure to use the `feature/drag-and-drop` branch
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None found
FREQUENCY : always
GNU/LINUX Fedora 34 (x86_64)
Kernel 5.14.9-200.fc34.x86_64
openjdk 17 2021-09-14
OpenJDK Runtime Environment 21.9 (build 17+35)
OpenJDK 64-Bit Server VM 21.9 (build 17+35, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
Using Fedora 34 (GNOME), dragging and dropping a file on a JavaFX GridPane will produce a NullPointerException:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot read field "dragboard" because "this.this$0.dndGesture" is null
at javafx.graphics/javafx.scene.Scene$DropTargetListener.drop(Scene.java:3004)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.lambda$handleDragDrop$2(GlassSceneDnDEventHandler.java:111)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.handleDragDrop(GlassSceneDnDEventHandler.java:107)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleDragDrop$11(GlassViewEventHandler.java:772)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleDragDrop(GlassViewEventHandler.java:771)
at javafx.graphics/com.sun.glass.ui.View.handleDragDrop(View.java:714)
at javafx.graphics/com.sun.glass.ui.View.notifyDragDrop(View.java:1043)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:290)
at java.base/java.lang.Thread.run(Thread.java:833)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Git clone this repository (branch feature/drag-and-drop):
https://github.com/CodeDead/opal/tree/feature/drag-and-drop
Run the application, and drag and drop a file on the main window, and regardless of what you do, you will always get the following exception:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot read field "dragboard" because "this.this$0.dndGesture" is null
Problematic code in question:
/**
* Method that is invoked when a drag-over event is occurring
*
* @param dragEvent The {@link DragEvent} object
*/
@FXML
private void onDragOver(final DragEvent dragEvent) {
if (dragEvent.getGestureSource() != scpMain && dragEvent.getDragboard().hasFiles()) {
dragEvent.acceptTransferModes(TransferMode.COPY_OR_MOVE);
}
dragEvent.consume();
}
/**
* Method that is invoked when a drag-drop event occurred
*
* @param dragEvent The {@link DragEvent} object
*/
@FXML
public void onDragDropped(final DragEvent dragEvent) {
final Dragboard db = dragEvent.getDragboard();
boolean success = false;
if (db.hasFiles()) {
success = true;
}
dragEvent.setDropCompleted(success);
dragEvent.consume();
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The exception should not happen
ACTUAL -
The NullPointerException happens every single time you drag and drop a file
---------- BEGIN SOURCE ----------
Code available on GitHub:
https://github.com/CodeDead/opal/tree/feature/drag-and-drop
Please make sure to use the `feature/drag-and-drop` branch
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None found
FREQUENCY : always
- duplicates
-
JDK-8165749 java.lang.RuntimeException: dndGesture.dragboard is null in dragDrop
- Resolved
-
JDK-8293894 Drag and drop a file produces NullPointerException Cannot read field "dragboard"
- Closed