Redirect System.in to swing component

后端 未结 2 1532
礼貌的吻别
礼貌的吻别 2021-01-07 07:27

Hey guys I am making a terminal application using Swing and Apache Commons. I was able to redirect System.out and System.err to a JTextArea

2条回答
  •  一向
    一向 (楼主)
    2021-01-07 08:10

    You need to create your own implementation of an InputStream that takes its input from whatever Swing component you want… basically have a buffer that you copy text to from your Swing component and that serves as a source for the InputStream (which of course needs to block if no input is available).

提交回复
热议问题