← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #251466]: Sikuli log output to JTextArea

 

Question #251466 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/251466

    Status: Answered => Solved

Nathan Ash-Vie confirmed that the question is solved:
Really should have Googled it before posting as the solution turns out
to be quite simple, extend OutputStream to write to a text area:

public class Log extends OutputStream {

    private final JTextArea textControl;

    public Log(JTextArea control) {
        textControl = control;
    }

    @Override public void write(int b) throws IOException {
        
        // append the data as characters to the JTextArea control
        textControl.append(String.valueOf((char)b));
    }
}

Then switch the output:

PrintStream out = new PrintStream(new Log(keyLog));
System.setOut(out);

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.