Mega Code Archive

 
Categories / Java / Swing JFC
 

A text component has an action map with actions and keymaps with actions

import javax.swing.Action; import javax.swing.JTextField; import javax.swing.text.JTextComponent; import javax.swing.text.Keymap; public class Main {   public static void main(String[] argv) throws Exception {     JTextComponent component = new JTextField();     if (component instanceof JTextComponent) {       JTextComponent textComp = (JTextComponent) component;       Keymap keymap = textComp.getKeymap();       while (keymap != null) {         Action[] actions = keymap.getBoundActions();         for (int i = 0; i < actions.length; i++) {           Action action = actions[i];         }         Action defaultAction = keymap.getDefaultAction();         keymap = keymap.getResolveParent();       }     }   } }