【发布时间】:2014-06-03 22:19:52
【问题描述】:
我正在尝试在 JButton 中获取两行文本
文本应该显示在
和 /> 和 just like this 之间
但由于某种原因,它在我的 for 循环中不起作用
JButton title[] = new JButton[6];
JButton button[] = new JButton[30];
String[] titleText = {"World Religion", "New Title", "New Title", "New Title", "New Title", "New Title"};
//
for (int i=0; i<6; i++) {
title[i] = new JButton();
title[i].setText("<html> <br /> </html>"+titleText[i]);
add(title[i]);
}
【问题讨论】:
-
因为你没有在
<html>标签之间附加它? -
那我该怎么做呢? @Origineil
-
不确定为什么要在文本之前或之后空行,但您应该考虑使用按钮边距作为替代方案
标签: java swing for-loop jbutton