How to change mouse cursor during mouse-over action on hyperlinks : JEditorPane « Swing « Java Tutorial






import javax.swing.JEditorPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLFrameHyperlinkEvent;

public class Main implements HyperlinkListener {
  private JEditorPane pane;

  public Main(JEditorPane jep) {
    pane = jep;
  }

  public void hyperlinkUpdate(HyperlinkEvent he) {
    HyperlinkEvent.EventType type = he.getEventType();
    if (type == HyperlinkEvent.EventType.ENTERED) {
      System.out.println(he.getURL().toString());
    } else if (type == HyperlinkEvent.EventType.EXITED) {
      System.out.println("exit");
    } else if (type == HyperlinkEvent.EventType.ACTIVATED) {
      if (he instanceof HTMLFrameHyperlinkEvent) {
        HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) he;
        HTMLDocument doc = (HTMLDocument) pane.getDocument();
        doc.processHTMLFrameHyperlinkEvent(evt);
      } else {
        try {
          pane.setPage(he.getURL());
          System.out.println(he.getURL().toString());
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
}








14.35.JEditorPane
14.35.1.Loading HTML Documents as a StyledDocument into a JEditorPane
14.35.2.Loading Web Page To JEditorPaneLoading Web Page To JEditorPane
14.35.3.Using Actions with Text Components: JEditorPane
14.35.4.Show html
14.35.5.Change mouse cursor during mouse-over action on hyperlinks
14.35.6.JEditorPane Look and Feel
14.35.7.How to change mouse cursor during mouse-over action on hyperlinks