This is what I have done so far, it works just fine, but when I double click, the double click event is fired and the single click event is fired, when I single click only the single click is fired of course.
long currentMillis = System.currentTimeMillis();
addEventFilter(MouseEvent.MOUSE_CLICKED, e -> {
long currentClickedMillis = System.currentTimeMillis();
long diffMillis = currentClickedMillis - currentMillis;
currentMillis = currentClickedMillis;
if (diffMillis > 500) {
fireEvent(new FlightListEvents(FlightListEvents.FLIGHT_BUTTON_CLICKED, this.aircraft));
} else {
fireEvent(new FlightListEvents(FlightListEvents.FLIGHT_BUTTON_DOUBLE_CLICKED, this.aircraft));
}
});
The other solutions on Stack Overflow do not work! They just count numbers of clicks and still have the same problem I have now.