Java Swing: display console messages into UI JTextArea

I have a small project which should work as a desktop application but run some tasks on background.

So, I wanted to place console information into UI component JTextArea. Google search brought me a wonderful solution Message Console.

usage is very simple:

JPanel panel = new JPanel();
JTextArea consoleOutput = new JTextArea(5, 20);
consoleOutput.setMargin(new Insets(5,5,5,5));

panel.add(new JScrollPane(taskOutput), BorderLayout.CENTER);
        MessageConsole mc = new MessageConsole(taskOutput);
        mc.redirectOut(Color.BLUE, null);
        mc.redirectErr(Color.RED, null);

1 comment

Leave a Reply

%d bloggers like this: