0

I am working in a tool which requires the user to interact with a console and for each typed command there is a graphic representation with the result of the command. I would like to have a single JavaFX app with a TextArea serving as the console for the spring-shell app and a canvas serving as the visualization output.

How can I replace standard input / output used by spring-shell with a TextArea?

Thanks

  • Are you running the shell in the same process as JavaFX or in a different process? If the latter, just launch the process with `ProcessBuilder`, get a `Process`, and then you can write to its standard input and read from its standard output and standard error (make sure to read both lest the buffers fill up and the process hangs). You'll want to do that in separate threads, which means you'll have to communicate with the _JavaFX Application Thread_ to update the `TextArea`. – Slaw Apr 21 '20 at 21:11
  • Thank you for your response @Slaw. I am running the shell in the same JavaFX process. I would like to write the command in the `TextArea`, hit Enter and execute one of the commands I have registered as spring-shell available commands. The method which defines what the command does might require to update the Canvas side of the JavaFX app. I am afraid that if I use another process I won't have direct communication with the JavaFX components until the command completes its execution. – Orlando Garcia Apr 22 '20 at 03:31
  • Check out this: https://stackoverflow.com/questions/13841884/. If [tag:spring-shell] uses standard input/output you can replace the streams with e.g. `System.setOut(...)`. If you can tell spring-shell to use a custom input/output stream the process is the same, it just happens on the spring level rather than the system level. Keep in mind that the former approach will redirect _all_ system output to your text area. – Slaw Apr 22 '20 at 04:31

0 Answers0