/** Attempt to find the editor keystroke for the given action. */ private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey) { KeyStroke[] ret = new KeyStroke[] {defaultKey}; JTextComponent comp = getComponent(); if (editorActionName != null && comp != null) { TextUI textUI = comp.getUI(); Keymap km = comp.getKeymap(); if (textUI != null && km != null) { EditorKit kit = textUI.getEditorKit(comp); if (kit instanceof BaseKit) { Action a = ((BaseKit) kit).getActionByName(editorActionName); if (a != null) { KeyStroke[] keys = km.getKeyStrokesForAction(a); if (keys != null && keys.length > 0) { ret = keys; } else { // try kit's keymap Keymap km2 = ((BaseKit) kit).getKeymap(); KeyStroke[] keys2 = km2.getKeyStrokesForAction(a); if (keys2 != null && keys2.length > 0) { ret = keys2; } } } } } } return ret; }