From eugener in ControlsFX mailing list
public void execute(ActionEvent ae) {
if (ae.getSource() instanceof Dialog ) {
((Dialog) ae.getSource()).setResult(this);
}
}
The above sets the result of the Dialog
to be the current Action
and closes the Dialog
But maybe that is a little redundant as I can simply call:
((Dialog) ae.getSource()).hide();
.hide()
hides the Dialog
and also sets the current action as the result.
I can't suggest which is a better solution (hide()
was suggested by jewelsea)
In addition I would suggest to always override the toString()
method of class AbstractDialogAction
, in order to get readable result from:
Action response = dialog.showConfirm();
System.out.println("RESPONSE = "+ response.toString());