Using DialogFX lib directly or w/i JFXtras, designate same button as default & cancel (example use case: prompting user to delete something, want to default in all cases to "No" button). Calls to setDefaultButton() & setCancelButton() work, code executes fine on Mac (ENTER & ESCAPE both return value for designated button), but not on Windows. Tested on at least two Windows machines with same results.
Some sample code to setup dialog is:
List<String> buttonLabels = new ArrayList<>(2);
buttonLabels.add("Affirmative");
buttonLabels.add("Negative");
DialogFX dialog = new DialogFX(Type.QUESTION);
dialog.setTitleText("Question Dialog Box Example");
dialog.setMessage("This is an example of an QUESTION dialog box, created using DialogFX. This also demonstrates the automatic wrapping of text in DialogFX. Would you like to continue?");
dialog.addButtons(buttonLabels, 1, 1);
int i = dialog.showDialog();
System.out.println("Return code=" + i);
DialogFX.java attached, also available via GitHub.
Some sample code to setup dialog is:
List<String> buttonLabels = new ArrayList<>(2);
buttonLabels.add("Affirmative");
buttonLabels.add("Negative");
DialogFX dialog = new DialogFX(Type.QUESTION);
dialog.setTitleText("Question Dialog Box Example");
dialog.setMessage("This is an example of an QUESTION dialog box, created using DialogFX. This also demonstrates the automatic wrapping of text in DialogFX. Would you like to continue?");
dialog.addButtons(buttonLabels, 1, 1);
int i = dialog.showDialog();
System.out.println("Return code=" + i);
DialogFX.java attached, also available via GitHub.