Jason
Jason

Reputation: 1

Do Something When href is Clicked

So, I have a JEditorPane with a bunch of text, and I want to be able to click on some the text enclosed in a tag, and have it activate some function, similar to the onclick in JavaScript with HTML. I've tried doing this with hrefs and <a> tags, but as I was not going to a website, it didn't work out for me.

So, how can I click on text enclosed in a tag in a JEditorPane and then do something accordingly?

Upvotes: 0

Views: 96

Answers (1)

Tom Hawtin - tackline
Tom Hawtin - tackline

Reputation: 147154

You want JEditorPane.addHyperlinkListener to handle to event and load the relevant page or perform another action.

Upvotes: 0

Related Questions