Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我制作了一个 java swing GUI。现在我想在上面显示一条静态消息,但消息是多行的,而 JLabel 是单行的。
如何显示该消息?
我们可以设置 JLabel 的任何属性来显示多行消息吗?
我是否必须为多行使用多个 JLabel?
还有其他方法可以显示该消息吗?
如何在 Swing 组件中使用 HTML
显示多行文本
你可以做
JLabel l = new JLabel("<html><p>Hello World! blah blah blah</p></html>");
它会在适当的地方自动包装它。