JavaFX menu items display shortcuts on the right
•
Java
Take the menu item in the edit menu in JavaFX scene builder as an example
See how they display the shortcut on the right? Is there a simple way to achieve the same effect using JavaFX? thank you.
Solution
You can add accelerator keys in the scene builder or add them directly to the fxml file, as shown below
<MenuItem mnemonicParsing="true" onAction="#mnuSaveAction" text="%menu.title.save" fx:id="mnuSave"> <accelerator> <KeyCodeCombination alt="UP" code="S" control="DOWN" Meta="UP" shift="UP" shortcut="UP" /> </accelerator> </MenuItem>
If you use "in JavaFX" to indicate that you do not use fxml, you can use mnusave setAccelerator(KeyCombination);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码