Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
NullPointerException when try to get Mouse Event type in drag and drop.
Hi,
I want to display a message when user made invalid drops. Hence i have written code to get the mouse event type. If it '8' means user released mouse (dragging is end). It is working good as expected, but some NullPointerException is comming always in the log. Please suggest how to avoid this NullPointerException.
@Override
public boolean accept( final DragAndDropEvent dragEvent ) {
final Component compdestination = dragEvent.getTargetDetails().getTarget();
if( compdestination instanceof DragAndDropWrapper ) {
final WrapperTargetDetails details = (WrapperTargetDetails) dragEvent.getTargetDetails();
int typeVal = details.getMouseEvent().getType(); // <<<< NPException is coming here.
if( typeVal == 8 ) {
displayInvalisDrop();
}
}
}
Here is the log message
java.lang.NullPointerException: null
at com.vaadin.shared.MouseEventDetails.deSerialize(MouseEventDetails.java:175)
at com.vaadin.event.dd.TargetDetailsImpl.getMouseEvent(TargetDetailsImpl.java:51)
Hi,
I couldn't reproduce this behavior. Could you post the rest of the code?