开发者

Hyperlink in JTextField

开发者 https://www.devze.com 2023-01-15 14:06 出处:网络
Is there some way to display text as hyperlink in JTextField so that when u开发者_开发问答ser presses it opens the link in a browserYou can\'t do that. Instead you want to use a JEditorPane:

Is there some way to display text as hyperlink in JTextField so that when u开发者_开发问答ser presses it opens the link in a browser


You can't do that. Instead you want to use a JEditorPane:

http://download.oracle.com/javase/tutorial/uiswing/components/editorpane.html


Technically, you can override some methods of JTextField, like onClick(..), so you can check what you clicked at and if it starts with "www" or "http", open default web browser with that link as a parameter. But try to look at other text components, probably there will be some that can open link "by default".

0

精彩评论

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