An alert of type CONFIRMATION by default shows ButtonTypes OK and CANCEL. When providing other buttons type to the constructor using Java code, OK and CANCEL do not show up.
When not using Java code, but instead declare the alert instance using FXML, the provision of ButtonTypes leads to the weird result of having both, the provided buttons AND the default buttons.
For example:
<Alert alertType="CONFIRMATION" >
<buttonTypes>
<ButtonType fx:constant="YES" />
<ButtonType fx:constant="NO" />
</buttonTypes>
</Alert>
The reasons is that the Alert constructor does not define "buttonTypes" as @NamedArgument, while setting the buttonTypes property does not clear existing buttons.
There actually is no way in FXML to get rid of the default buttons!
This is a very ugly flaw as either the designer has to modify the design (using OK / CANCEL instead of YES / NO), or he needs a Java programmer to change the controller's source code each time he wants to use a different ButtonType.
When not using Java code, but instead declare the alert instance using FXML, the provision of ButtonTypes leads to the weird result of having both, the provided buttons AND the default buttons.
For example:
<Alert alertType="CONFIRMATION" >
<buttonTypes>
<ButtonType fx:constant="YES" />
<ButtonType fx:constant="NO" />
</buttonTypes>
</Alert>
The reasons is that the Alert constructor does not define "buttonTypes" as @NamedArgument, while setting the buttonTypes property does not clear existing buttons.
There actually is no way in FXML to get rid of the default buttons!
This is a very ugly flaw as either the designer has to modify the design (using OK / CANCEL instead of YES / NO), or he needs a Java programmer to change the controller's source code each time he wants to use a different ButtonType.