498
499 if (mnemonic > 0) {
500 addMnemonic(counter, mnemonic);
501 }
502 }
503 }
504
505 /**
506 * Resets the mnemonics bindings to an empty state.
507 */
508 private void resetMnemonics() {
509 if (mnemonicToIndexMap != null) {
510 mnemonicToIndexMap.clear();
511 mnemonicInputMap.clear();
512 }
513 }
514
515 /**
516 * Adds the specified mnemonic at the specified index.
517 */
518 private void addMnemonic(final int index, final int mnemonic) {
519 if (mnemonicToIndexMap == null) {
520 initMnemonics();
521 }
522 // [2165820] Mac OS X change: mnemonics need to be triggered with ctrl-option, not just option.
523 mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, Event.ALT_MASK | Event.CTRL_MASK), "setSelectedIndex");
524 mnemonicToIndexMap.put(Integer.valueOf(mnemonic), Integer.valueOf(index));
525 }
526
527 /**
528 * Installs the state needed for mnemonics.
529 */
530 private void initMnemonics() {
531 mnemonicToIndexMap = new Hashtable<Integer, Integer>();
532 mnemonicInputMap = new ComponentInputMapUIResource(tabPane);
533 mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(tabPane, JComponent.WHEN_IN_FOCUSED_WINDOW));
534 SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_IN_FOCUSED_WINDOW, mnemonicInputMap);
535 }
536
537 /**
|
498
499 if (mnemonic > 0) {
500 addMnemonic(counter, mnemonic);
501 }
502 }
503 }
504
505 /**
506 * Resets the mnemonics bindings to an empty state.
507 */
508 private void resetMnemonics() {
509 if (mnemonicToIndexMap != null) {
510 mnemonicToIndexMap.clear();
511 mnemonicInputMap.clear();
512 }
513 }
514
515 /**
516 * Adds the specified mnemonic at the specified index.
517 */
518 @SuppressWarnings("deprecation")
519 private void addMnemonic(final int index, final int mnemonic) {
520 if (mnemonicToIndexMap == null) {
521 initMnemonics();
522 }
523 // [2165820] Mac OS X change: mnemonics need to be triggered with ctrl-option, not just option.
524 mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, Event.ALT_MASK | Event.CTRL_MASK), "setSelectedIndex");
525 mnemonicToIndexMap.put(Integer.valueOf(mnemonic), Integer.valueOf(index));
526 }
527
528 /**
529 * Installs the state needed for mnemonics.
530 */
531 private void initMnemonics() {
532 mnemonicToIndexMap = new Hashtable<Integer, Integer>();
533 mnemonicInputMap = new ComponentInputMapUIResource(tabPane);
534 mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(tabPane, JComponent.WHEN_IN_FOCUSED_WINDOW));
535 SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_IN_FOCUSED_WINDOW, mnemonicInputMap);
536 }
537
538 /**
|