When a label is associated with a component, you should call
setLabelFor() to make the association explicit and then set a
mnemonic on the label. The associated component will get the
focus when the mnemonic is activated.
JLabel label = new JLabel("Name:");
label.setDisplayedMnemonic('N');
label.setLabelFor(component);
当你想让你一个标签与组件关联时,你应该调用setLabelFor方法来显式关联,然后为这个标签设置一个助记符。
当助记符被激活时,这个被关联的组件将获得激活