How to trigger a hyperlink using a keystroke in a Swing JEditorPane
问题 I'm trying to fire hyperlinks in a JEditorPane using the "Enter" keystroke. So that the hyperlink (if any) under the caret will fire rather than having to click with the mouse. Any help would be appreciated. 回答1: First of all the HyperlinkEvent is only fired on a non-editable JEditorPane so it will be difficult for the users to know when the caret is over a link. But if you do want to do this, then you should be using Key Bindings (not a KeyListener) to bind an Action to the ENTER KeyStroke.