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

查看:313
本文介绍了在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> 启动文本,在标签中使用HTML格式(可能会添加一些内嵌样式正文开放元素)。

  2. 添加每一行,以结尾< br> < p> (或< li> 如果添加< ul> ;< li> 到前缀)。

  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天全站免登陆