在 JLabel 中附加文本 [英] Append text in JLabel

查看:43
本文介绍了在 JLabel 中附加文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 JLabel 实现 JTextArea 的效果?

How would I go about achieving the effect of JTextArea with JLabel?

我希望每次在下一行单击按钮时都显示输出,而不是替换已经存在的文本,即像 JLabel 的附加方法一样?

I want the output to be displayed every time the button is clicked on the next line down instead of replacing what text is already there, i.e. like an append method for JLabel?

我只是希望它遵循与 JTextArea.append 相同的行为.

I just want it to follow the same behavior as JTextArea.append.

我还想为每一行添加超链接.

Also I want to add hyperlink to each line.

推荐答案

  1. 通过以前缀 开头的文本在标签中使用 HTML 格式(可能在 body 开始元素中添加一些内嵌样式).
  2. 添加每一行,以

    (或

  3. 如果添加
    • 到前缀).
  1. Use HTML formatting in the label by starting the text with prefix <html><body> (possibly add some in-line styles in the body opening element).
  2. Add each line, ending with <br> or <p> (or <li> if adding <ul><li> to the prefix).

<小时>

另请参阅如何在 Swing 组件中使用 HTML.对于这样的宝石......


See also How to Use HTML in Swing Components. For such gems as..

这篇关于在 JLabel 中附加文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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