Changing the mouse pointer in JtextPane

别说谁变了你拦得住时间么 提交于 2019-12-04 04:35:13

问题


I have a JTextPane which has the content type text/plain. I set some texts to 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


回答1:


You could try this:

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

Where pane is your JTextPane.




回答2:


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.



来源:https://stackoverflow.com/questions/6615940/changing-the-mouse-pointer-in-jtextpane

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!