可以说我有一个字符串的JLabel,选择JLabel显示在JFrame:如何格式化的JLabel/JTextField中所以文本换行
public String content="Hello fellow stack-overflowers, I want to format this output";
public JLabel jL = new JLabel();
一旦做到以下几点:
jL.setText(content);
我得到这个输出:
Hello fellow stack-overflowers, I want to for..
但我真正想要的是文本不会继续超过标签或文本字段的长度,而是m每4个字左右换一个换行符,例如:
Hello fellow stack-overflowers, I want
to format this output
询问是否需要更多信息。
您可以使用''标签JLabel。请参阅['是否有JLabel的“自动换行”属性?](http://stackoverflow.com/questions/7861724/is-there-a-word-wrap-property-for-jlabel)对于JTextField,我会说使用JTextArea来代替。 – Radiodef 2014-11-05 00:27:57