JButton のニーモニックを非アクティブ化するには、助けが必要です。実際には、ニーモニックを「Alt C」に設定したサードパーティの API を使用しています。したがって、このニーモニックを削除し、この compButton に何も設定しない (ニーモニックを削除する) 必要があります。
// Alt + 'C' selects the comp.
compButton.setMnemonic(KeyEvent.VK_C);
を使ってみてはどうですかcompButton.setMnemonic(0);
編集:
私が見たjavax/swing/AbstractButton.java
:
/**
* Returns key bindings associated with this object
*
* @return the key bindings, if supported, of the object;
* otherwise, null
* @see AccessibleKeyBinding
* @since 1.4
*/
public AccessibleKeyBinding getAccessibleKeyBinding() {
int mnemonic = AbstractButton.this.getMnemonic();
if (mnemonic == 0) {
return null;
}
return new ButtonKeyBinding(mnemonic);
}
したがって、compButton.setMnemonic(0);
よりもさらによく見えますcompButton.setMnemonic(-1);
。