GUI Commands 2.0 has arrived! Find out what's new and improved.
Embedding in HTML

It is easy to embed commands within HTML using the Swing JEditorPane.  This allows standard anchor tags to activate a command.

   JEditorPane editorPane = new JEditorPane();
   editorPane.setEditorKit(new HTMLEditorKit());
   editorPane.addHyperlinkListener(new CommandHyperlinkListener());

When the following anchor tag is displayed in the editor pane, any clicks on 'My Command' will activate the command registered with the id of 'my.command.id'.

   <a href='command://my.command.id'>My Command</a>

It is also possible to provide hints to the command using the following syntax.

   <a href='command://my.command.id?hintName=hintValue'>My Command</a>
   
   <a href='command://my.command.id?aName=aValue,bName=bValue'>My Command</a>

If you are building the anchor tags programmatically, the CommandHyperlinkListener has several static methods that read the text and tool tip from the command and build the anchor tag to match. It uses the 'html' face if available, otherwise the default face is used.

   String anchorString = CommandHyperlinkListener.buildAnchorString(myCommand);