JavaFX menu item show shortcuts on right hand side


Take for example the menu items from the edit menu in JavaFX Scene Builder

See how they display the shortcuts on the right? Is there any easy way to achieve the same effect using JavaFX? Thanks.

1/18/2014 8:44:33 PM

Accepted Answer

You can add an accelerator key in scene builder or add it directly in the fxml file like so

      <MenuItem mnemonicParsing="true" onAction="#mnuSaveAction" text="" fx:id="mnuSave">
          <KeyCodeCombination alt="UP" code="S" control="DOWN" meta="UP" shift="UP" shortcut="UP" />

If by "in javafx" you mean without using fxml you can use mnuSave.setAccelerator(KeyCombination);

1/18/2014 8:43:31 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow