Hello,
My Java application runs native code written in c++.
I need to display some messages from c++ std:cout into a JTextPane.
First, I tried to display the standard PrintStream output "System.out" but it only shows Java messages. Here is my code:
import java.awt.Color;
import java.io.OutputStream;
import java.io.PrintStream;
import javax.swing.JTextPane;
public class LogTextPane extends JTextPane {
private static final long serialVersionUID = 1L;
private MyPrintStream mps;
protected LogTextPane(){
super();
this.setBackground(new Color(1,1,0.8f));
mps = new MyPrintStream(System.out);
System.setOut(mps);
}
class MyPrintStream extends PrintStream {
MyPrintStream(OutputStream out){
super(out);
}
public void println(String string){
setText(getText() + string + "\n");
}
public void print(String string) {
setText(getText() + string);
}
}
}
Anyone has an idea? Thanks in advance
Best