如何在JTextArea中添加可点击的URL? [英] How can I add a clickable URL in a JTextArea?

查看:110
本文介绍了如何在JTextArea中添加可点击的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个应用程序,并且正在使用JTextArea显示一些文本.现在,我想在文本区域中显示一些可点击的URL以及普通文本,如果用户单击URL,则URL引用的网页应在新的Web浏览器窗口中打开.

I am writing an application and in that I am using JTextArea to display some text. Now I want to show some clickable URL in text area along with the normal text and I want if user click on the URL then the web page that URL referring to should open in new web browser window.

推荐答案

将JEditorPane与HTMLEditorKit或JTextPane一起使用,并将内容类型设置为"text/html"

Use JEditorPane with HTMLEditorKit or JTextPane and set content type to "text/html"

这篇关于如何在JTextArea中添加可点击的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆