2

JButton のニーモニックを非アクティブ化するには、助けが必要です。実際には、ニーモニックを「Alt C」に設定したサードパーティの API を使用しています。したがって、このニーモニックを削除し、この compButton に何も設定しない (ニーモニックを削除する) 必要があります。

    // Alt + 'C' selects the comp.
     compButton.setMnemonic(KeyEvent.VK_C);
4

1 に答える 1

3

を使ってみてはどうですか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);

于 2014-03-25T15:17:37.113 に答える