|
[SOLVED] hyperlinks in JTextPane
Hi,
I have a java applet with a JTextPane component, to which text is added like this:
<code>
textPane = new JTextPane();
doc = textPane.getStyledDocument();
doc.insertString(doc.getLength(), message, doc.getStyle(style));
</code>
What I would like is to be able to add hyperlinks to this text, such that clicking one of them will bring up a separate browser window, in which one url or another will load. I know that the way to achieve the browser window is to use
<code>
getAppletContext().showDocument(userUrl,target)
</code>
What I don't know is how to connect a string added to the JTextPane to such a method. Is this at all possible? Or would I need to use components such as labels rather than strings to achieve it? The drawback that I see with such a solution is that it would not be possible to highlight/select text.
Thank you very much for your help
|