2011-08-19 58 views
4

I have a JTextPane which displays a link to which on click should open a page in the browser.如何使用<a href> tag in JTextPane

The link is set as a text to the TextPane as shown:

<a href=http://www.google.com target=_blank>Read more..</a> 

Also below shows how the link looks like in my pane:

When I click on this nothing happends, do anyone know why?

回答

3

You need JTextPane to be non-editable for link to activate, and install HyperlinkListener on it to provide action which should be done when link clicked.