Good Evening, What can I do to have the output from jTExtArea like in the console? You can see the image how it is, I use .append to show the output in jTextArea Image
Code:
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();
}
Set the font to monospaced.
t1.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
Edit:
And add new line in main iteration and use string format.
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");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.