I read the source, HyperlinkEvent is generated by mouseClick(). That means your mouseClick() will happen before hyperlinkUpdate(). Because a Mouse Click event will be generated first, then JEditorPane try to check if a link is clicked. If a link is clicked, a HyperlinkEvent will be dispatched and hyperlinkUpdate() is called.
1. try to use another framework, avoid processing mouseClick and hyperlinkUpdate at the same time
2. If have to, under mouseClick() you must check the mouse position is within a link before doing other things.
There are two types of link, <a href> and <map>. Copy the source code from
HTMLEditoreKit.LinkController can solve <a href>. But you cannot solve <map>, unless you write your own codes. Because to determine if it's a <map> link, HTMLDocument and java.swing.text.html.Map class are used. You're unlucky, Map is package-access class. So methods of Map, such as Map.getArea(), cannot be accessed in your codes because I don't think you'll put your code under java.swing.text.html package.
If no <map>, I can give you a solution. If you want to handle <map>, try to write your own code.