DEV Community

özkan pakdil
özkan pakdil

Posted on

How to assign shortcut to a button in fxml

I wanted to assign a button in fxml a keyboard shortcut. below is the example how to do that.

<Button mnemonicParsing="true" text="_Click Me">
Enter fullscreen mode Exit fullscreen mode

Now that button will have underscore on that "C" and user can call it automatically with key combination of ALT+C, The form that button should have the focus.
Example: https://github.com/ozkanpakdil/swaggerific/blob/main/src/main/resources/com/mascix/swaggerific/tab-request.fxml#L29

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay