问题描述
我一直在使用SceneBuilder,我发现它应用 mnemonicParsing
的属性并将其等同于 false
对于我制作的每个节点
。
I have been working with SceneBuilder and I observe that it applies the attribute of mnemonicParsing
and equates it to false
for every Node
that I make.
究竟是什么?它在 Layout.xml
中有什么区别?
What exactly is it? What difference does it make in Layout.xml
?
推荐答案
这是指到。它注册一个键盘快捷键来激活元素(使用文本
+ (Windows, don't know if it's the same key on other OS too)). E.g.
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!");
}
});
还会打印 Hello World!
,如果用户按 + S。
Will also print Hello World!
, if the user presses + S.
如果 mnemnonicParsing
,则不会发生这种情况是 false
。在这种情况下, _
也将打印正常,而不是在下面的字母下划线。
This doesn't happen, if mnemnonicParsing
is false
. In this case the _
will also be printed "normally" instead of underlineing the following letter.
这篇关于什么是“助记符分析”? Java FX中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!