3

I have MenuItem ,

 MenuItem menuItem = new MenuItem("OP");
 menuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+S"));

I want to display only the text(Ctrl+S) and not have any action for the accelerator, because i have keyBindings for that.With both in place the action occurs twice.

I found a similar question, [Add accelerator description to JMenuItem in GUI, without actually adding an accelerator

But it is for Swing.

How can i do this in JavaFX.

Community
  • 1
  • 1
user3164187
  • 1,382
  • 3
  • 19
  • 50

1 Answers1

2

This worked for me:

Scene scene = ...;
stage.setScene(scene);
stage.show();
scene.getAccelerators().clear();

The help text is displayed, but the action does not fire on key press.

Rogach
  • 26,050
  • 21
  • 93
  • 172