开发者

Changing the mouse pointer in JtextPane

I have a JTextPane which has the content type text/plain. I set some texts to开发者_JAVA技巧 that JTextPane and it contain some texts which display URLs. I want to change the mouse pointer when I point the mouse to that text only into the hand pointer. Is this function achievable? Note: I have the content of the JTextPane as text/plain. It cannot be changed to text/html

thanx


You could try this:

pane.setCursor(new Cursor(Cursor.HAND_CURSOR));

Where pane is your JTextPane.


Did you read my answer in your posting on Adding tooltips to JTextPane?

Well the concept is the same. You use a MouseListener and convert the mouse point to get the text at the caret position. When you are over a url text then you change the cursor.

The Utilities class might help you access the text at the caret location.

If you need more help then post your SSCCE that shows what you have tried and shows what problems you are having.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜