First, can anyone explain to me, why my MouseEvent
gets consumed no matter which Alert
-Option I choose? I guess it has something to do with calling an
I debugged it and my guess is that it's a bug, you should file a bug report. The event isn't consumed as long as you remain in the EventFilter. Sometimes after that code was processed, the event appears to be consumed in the bubbling event. That's probably a side-effect of the nested eventing in the Alert class.
You can solve that problem easily by always consuming the event and setting the checkbox manually, i. e.
if ( alert.showAndWait().get().equals( ButtonType.OK ) )
{
System.out.println( "Yes, consume Event" );
event.consume();
}
else
{
System.out.println( "No, do NOT consume Event" );
//<-- Why is the Event consumed anyway? onAction won´t be called.
// always consume the event
event.consume();
// trigger the change manually
checkBox.setSelected(!checkBox.isSelected());
}
However, you got another problem there, e. g. if a user triggers the checkbox selection event by keyboard (space bar). But you explicitly caught the mouse event, so I leave it at that (hint: you could e. g. revert the selection in the onAction event).
Tried it on Win7 x64 with Java 8u66 and Java 8u74.