新线\\ n不中JButton.setText工作(QUOT; fnord \\ nfoo"); [英] New Line \n is not working in JButton.setText("fnord\nfoo") ;

查看:186
本文介绍了新线\\ n不中JButton.setText工作(QUOT; fnord \\ nfoo");的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个JButton,我想列出多条线路上的信息。我试图 \\ n 作为新行字符,但它没有工作。下面code:

On a JButton, I want to list information on multiple lines. I tried \n as a new line character but it didn't work. The following code:

JButton.setText("fnord\nfoo") ;

将显示为:

fnordfoo

我如何强制换行?

How do I force a line break?

推荐答案

JButton的接受HTML,因此对于断行的工作使用:

JButton accepts HTML, so for the line break to work use:

 JButton.setText("<html>fnord<br />foo</html>");

这篇关于新线\\ n不中JButton.setText工作(QUOT; fnord \\ nfoo&QUOT;);的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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