如何在 Java GUI 上添加多行标签?

发布于 2024-08-08 19:29:08 字数 176 浏览 1 评论 0原文

我做了一个java swing GUI。现在我想在其上显示一条静态消息,但该消息是多行的,而 JLabel 是单行的。

我怎样才能显示该消息?

我们可以设置 JLabel 的任何属性来显示多行消息吗?

我是否必须为多行使用多个 JLabel?

还有其他方法可以显示该消息吗?

I have made a java swing GUI. Now I want to display a static message on that but the message is multi-line and the JLabel is single line.

How can I display that message?

Is there any property of JLabel which we can set to display the multiple line message?

Will I have to use several JLabels for multiple lines?

Is there any other way I can display that message?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冰雪梦之恋 2024-08-15 19:29:08

你可以这样做

JLabel l = new JLabel("<html><p>Hello World! blah blah blah</p></html>");

,它会在适当的地方自动包装它。

You can do

JLabel l = new JLabel("<html><p>Hello World! blah blah blah</p></html>");

and it will automatically wrap it where appropriate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文