Formatting JEditorPane Cursor, Tooltips, Links

I am currently using Java Swing to create a JEditorPane, primarily for its ability to have hyperlinks. I was able to successfully display links and force them to perform click-through behavior, but I had formatting problems.

  • How can I set the cursor so that it is usually an arrow, but changes to a text cursor when I hover over text? (Essentially, cursor behavior in a web browser). I tried

    EditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR))
    

    but that made him a text cursor everywhere, even if he doesn't hang over the text. Right now, hovering over the link, a pointer arrow is displayed; I would also like to support this functionality.

  • What is the best way to display tooltips or mouse cursor text when you hover over a link? I tried to change the title attribute of the link, but nothing appeared.

  • I tried to embed links to go to the page subsection, as http://en.wikipedia.org/wiki/Xkcd#History will lead you directly to the History of Wikipedia xkcd subsection. How can i do this?

The answer to any of them would be great (and a few would be cool xP). Many thanks for your help!

+3
source share
3 answers

As you said, you can just give answers to one point, let me try one by one, here is the answer for your last Point 3

Just provide your tag id like this

<h1><a id = "top"></a>First Line</h1>

:

<p><a href = "#top">Return to TOP</a></p>

, PAGE.

+3

1 2 . , / setCursor() getToolTipText() .

+2

All Articles