System.out.println to JTextArea

后端 未结 5 1340
庸人自扰
庸人自扰 2020-12-16 06:10

EDIT: I have edited the post to clarify my question, now I myself, have more understanding.

I am essentially, as the title says, attempting to outpu

5条回答
  •  余生分开走
    2020-12-16 06:42

    The best way to do this I have found is very simple and seems to work very nicely. I've used it for years with no issues.

    JTextArea output = new JTextArea();
    PrintStream out = new PrintStream(new OutputStream() {
    @Override
        public void write(int b) throws IOException {
            output.append(""+(char)(b & 0xFF));
        }
    });
    System.setOut(out);
    System.out.println("TEST");
    

提交回复
热议问题