JEditorPane editor = (JEditorPane) e.getSource(); HTMLEditorKit kit = (HTMLEditorKit) editor.getEditorKit(); if (! editor.isEditable()) { Document doc = editor.getDocument(); if (doc instanceof HTMLDocument) { Cursor newCursor = kit.getDefaultCursor(); HTMLDocument htmlDoc = (HTMLDocument) doc; Point loc = e.getPoint(); int pos = editor.viewToModel(loc); Element el = htmlDoc.getCharacterElement(pos); if (pos < el.getStartOffset() || pos >= el.getEndOffset()) el = null; if (el != null) { AttributeSet aAtts = (AttributeSet) el.getAttributes().getAttribute(HTML.Tag.A); if (aAtts != null) { if (el != lastAnchorElement) { if (lastAnchorElement != null) htmlDoc.updateSpecialClass(lastAnchorElement, HTML.Attribute.DYNAMIC_CLASS, null); lastAnchorElement = el; htmlDoc.updateSpecialClass(el, HTML.Attribute.DYNAMIC_CLASS, "hover"); } newCursor = kit.getLinkCursor(); } else { if (lastAnchorElement != null) htmlDoc.updateSpecialClass(lastAnchorElement, HTML.Attribute.DYNAMIC_CLASS, null); lastAnchorElement = null; } } else { if (lastAnchorElement != null) htmlDoc.updateSpecialClass(lastAnchorElement, HTML.Attribute.DYNAMIC_CLASS, null); lastAnchorElement = null; } if (editor.getCursor() != newCursor) { editor.setCursor(newCursor); } } }
      public void mouseMoved(MouseEvent e)      {        /*        These MouseInputAdapter methods generate mouse appropriate events around        hyperlinks (entering, exiting, and activating).        */        // FIXME: Not implemented.      }