是否有“自动换行"?JLabel 的属性? [英] Is there a "word wrap" property for JLabel?

查看:25
本文介绍了是否有“自动换行"?JLabel 的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 JLabel 中显示一些文本.基本上我是动态生成文本,然后应用一些 HTML 标签(例如,BRB)来格式化文本.最后,我将此格式化文本分配给我的 JLabel.

I am displaying some text in a JLabel. Basically I am generating that text dynamically, and then I apply some HTML tags (e.g., BR and B) to format the text. Finally I assign this formatted text to my JLabel.

现在我希望我的 Jlabel 在到达屏幕末尾时自动将文本换行到下一行,就像记事本中的自动换行"功能一样.

Now I want my Jlabel to automatically wrap the text to the next line when it reaches the end of screen, like the "Word Wrap" feature in Note Pad.

我该怎么做?

推荐答案

如果您将文本包裹在 ...</html>

更新:那么,您或许也应该设置最大尺寸.

UPDATE: You should probably set maximum size, too, then.

这篇关于是否有“自动换行"?JLabel 的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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