开发者

Disable hyperlinks in JTextPane

开发者 https://www.devze.com 2023-03-16 12:23 出处:网络
I have a JTextPane with HTML contents. Without changing the content type or calling setText, I would like disable the hyperlinks. I want

I have a JTextPane with HTML contents. Without changing the content type or calling setText, I would like disable the hyperlinks. I want

  • The hyperlinks to have the same style as the surrounding text (usually meaning no underline or blue color)
  • The mouse to not turn into a hand when I move开发者_C百科 it over hyperlinks

What is the easiest way to do this? I already know how to change the hyperlink listener, but now want the links to appear as normal text.


You can define desired style for your "a" tag. E.g. to set forn bigger use

((HTMLDocument)textPane.getDocument()).getStyleSheet().addRule("a {font-size:48px;}");
0

精彩评论

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