1

I would like to be able to add accelerator keys for the buttons that are provided as a part of the Alert Dialog Controls included with JavaFX.

I am unsure if this is possible using the standard alert types ERROR, INFORMATION, CONFIRMATION, WARNING?

I created my own login window - which doesn't use an Alert structure and it works as follows:

enter image description here

When the stage opens up.

Then when the user hits the "ALT" key:

enter image description here

I would like the ability to "Hot Key" the buttons on the Alerts in the system. However, I am unsure if I can use the standard alerts, or if I need to create my own, and if so, how should I do that.

I really would like to use the Dialogs natively, if at all possible.

Thanks.

purring pigeon
  • 4,141
  • 5
  • 35
  • 68

1 Answers1

0

As far as I understood your question, I think it isn't possible without some extra code.

Looking at the code of OpenJFX the labels of the buttons are localized and fixed.

You might just want to create some buttons on your own by using the apropiate constructor which takes some buttons where you can override the existing ones.

EDIT: after rethinking everything, I tried to recreate your problem. You can see that project on GitHub..

This is the special code:

public void showCustomizedAlertWindow() {
    Alert a = new Alert(AlertType.CONFIRMATION, "some content text", ButtonType.OK, ButtonType.CANCEL, ButtonType.FINISH);
    ((Button) a.getDialogPane().lookupButton(ButtonType.FINISH)).setText("_finished");
    a.show();
}

But be aware, you are removing localization-support of that buttons.

FibreFoX
  • 2,858
  • 1
  • 19
  • 41