rkcole.com
I once wrote an HTML custom-tag editor that required that a dialog box pop-up in response to a click on one of the hyperlinks. I developed the following technique to accomplish that task:
The technique can be summarized in the following steps:
Attach a HyperlinkListener to your JEditorPane.
In the hyperlinkUpdate event handler, look for a custom dialog protocol.
Invoke the dialog using a link that looks like this: <a href="dialog://something.com">Popup Dialog</a>
Then, in the HyperlinkListener, look for the "dialog" string in the HyperlinkEvent's description like this:
public void hyperlinkUpdate(HyperlinkEvent event)
{
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
{
/* Process our custom dialog hyperlinks */
if( (event.getDescription() != null)
&& event.getDescription().substring(0,6).equals("dialog") )
{
... popup a dialog ...
}
else
{
/* Process all other hyperlinks */
try
{
htmlPane.setPage(event.getURL());
} catch(IOException ioe)
{
// Some warning to user
}
}
}
}
.
.
.