Tuesday, August 25, 2015

Catch link clicks in JLabel

The javax.swing.JLabel allows to show a HTML document which contains multiple HTML links but there is not any way to catch click on the links. If such JLabel has only HTML link then you can just catch all clicks and open browser with the link, but if you have several links shown by JLabel then there is no way to separate them. For such case I have written small modification of JLabel which allows to separate clicked links inside JLabel, the Gist cand be found here.