What is the mnemonicParsing attribute in Java FX

I work with SceneBuilder, and I notice that it applies the mnemonicParsing attribute and equates it to false for every Node that I make.

What exactly? What is the difference in Layout.xml ?

+6
source share
1 answer

This refers to the Labeled.mnemonicParsing property. It registers a key combination for activating an element (using the letter following _ in text + Alt (Windows, I don’t know if it is the same key on another OS)). For instance.

 Button btn = new Button(); btn.setText("_Say 'Hello World'"); btn.setMnemonicParsing(true); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("Hello World!"); } }); 

Will also print Hello World! if the user presses Alt + S.

This does not happen if mnemnonicParsing is false . In this case, _ will also be printed "normal", and not underline the next letter.

+13
source

All Articles