晚上好,我可以做些什么来让jTExtArea的输出像在控制台中一样?如图所示,我使用.append在jTextArea Image中显示输出
代码:
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b1) {
for (int i = 0; i < a.pattern_cnt; i++) {
for (int j = 0; j < a.T_element_cnt; j++) {
System.out.printf("%.3f\t", a.O[i][j]); //console output
t1.append(a.O[i][j]+" ");//jtextarea output
}
System.out.println();
}发布于 2018-01-05 07:53:38
将字体设置为等宽字体。
t1.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));编辑:
并在主迭代中添加新行,并使用字符串格式。
for (int i = 0; i < a.pattern_cnt; i++) {
for (int j = 0; j < a.T_element_cnt; j++) {
System.out.printf("%.3f\t", a.O[i][j]); //console output
t1.append(String.format("%.3f\t", a.O[i][j]));//jtextarea output
}
System.out.println();
t1.append("\n");
}https://stackoverflow.com/questions/48105227
复制相似问题