簡體   English   中英

JTextArea輸出

[英]JTextArea Output

晚上好,如何在控制台中獲得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();


            }

將字體設置為等距。

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");

        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM