Hi, I've got a a few objects and all of them has got a HTML based description. Each description has got Hyperlink which actually has a link to represent an ID of the object. Question: How can I capture a Hyperlink click on these. I did attempt to use JLabel and JButton HTML capabilities, but none of them seems to work for Hyperlink tag. I did have a look at how JEditorPane works with "implements HyperlinkListener"...but I'm not looking at displaying a real URL but just want to capture a Hyperlink click. Pls help. Example: String htmlText = "<html>I love a person"; JLabel lb1 = new JLabel(htmlText); // or JButton b1 = new JButton(htmlText); // but then what?
You just need to add a Mouse Listener to the JLabel to catch the click. Example:
Joined: Jul 24, 2001
Originally posted by Matt Hansen: [B]You just need to add a Mouse Listener to the JLabel to catch the click. Example: [/B]
Heh, thanks Matt for replying. I understand what you're saying, but my JLabel only has certain portion is meant to be clickable...like the portion with the Hyperlink. YOur code above tells me the whole JLabel is clickable. Am I missing something here....I'm pretty new at Swing ------------------ Thank you. - Simon See firstname.lastname@example.org -after office hours- necro-mani-cide