title: How to get a specific action from the HTMLEditorKit?
body: <p>I want to create a simple test application with a <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/JEditorPane.html" rel="nofollow">JEditorPane</a> displaying some HTML content and a button which makes the selected text bold. The <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/text/html/HTMLEditorKit.html" rel="nofollow">HTMLEditorKit</a> already provides the necessary action for this button so I was able to use it with complicated code like this:</p>
  
  <pre><code>// Build action map
  Map&lt;String, Action&gt; actionMap = new HashMap&lt;String, Action&gt;();
  for (Action action: editor.getActions())
      actionMap.put("" + action.getValue(Action.NAME), action);
  
  // Get the action
  Action action = actionMap.get("font-bold");
  </code></pre>
  
  <p>But I'm pretty sure there is something wrong. I can't believe that I have to create this helper map to get the action by name. The only official method I found for retrieving the actions seems to be this <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/text/JTextComponent.html#getActions%28%29" rel="nofollow">getActions()</a> method of <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/JEditorPane.html" rel="nofollow">JEditorPane</a> which just returns an array.</p>
  
  <p>So is there a better way to fetch a specific action from an <code>EditorKit</code> and I simply missed it or is it just bad API design?</p>