Pregunta

I am making a Minecraft launcher, and i would like to make my own ftb-style console to go with it. any ideas on how i would redirect Minecraft's print stream to a JTextArea?

¿Fue útil?

Solución

You'll have to create an implementation of PrintStream and replace System.out and System.err with it, by System.setOut and System.setErr, respectively. You might also want to replace System.in for input, depending on whether this is for the MineCraft client or server.

There are many articles on piping PrintStreams to Swing components. On such article describing the process can be found here. A search engine query resembling "redirecting PrintStream to JTextPane" will also bring up a handful of links.

Otros consejos

You could use something like this StreamGobbler example: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=4

The other answers on this other SO question may also help: Capturing stdout when calling Runtime.exec

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top