I want to change the ActionMap of Swing JTextFields in my entire Application by replacing a few actions by my custom implmentations. For an explanation why you can refer to the following post:
How do I make the caret of a JTextComponent skip selected text?
This works well if I do this:
ActionMap map = (ActionMap)UIManager.get("TextField.actionMap");
map.put(DefaultEditorKit.backwardAction, new MyCustomAction());
The only remaining problem now is that so far I have only gotten this to work, when I execute that code after the first instantiation of a JTextField. However, ideally I would like to integrate this code in a custom look and feel or some other central place that does not have to know about the application. Calling
UIManager.getDefaults()
first does not change anything. The map returned by UIManager.get("TextField.actionMap") is still null afterwards.
Right now I am Stuck with putting a dummy new JTextField() in some initialization method of my application and then manipulate the action map which is very ugly.