Dialog to show logs from console

Hi, I am looking for how to show logs from console into a dialog.

My Objective: I have a backgroud task running (Its Runtime.getRuntime().exec() ,i.e, invoking terminal command), and I get the output (process.getInputStream). It is like, running a command in the terminal and getting line by line output in the console. I am doing the same thing from JAVA. The background task does this. Now I want to show the "Line by Line output" to the user through a dialog. Any idea on how I should approach this?

I tried DialogWrapper and JDialog. Doesn't seem to work. I need to print line by line data into JTextArea of the Dialog from the backgroud task...

Please help me out...

1 comment
Comment actions Permalink

I used SwingWorker to solve this.

The Dialog to show logs is in the Event Dispatch Thread. The backgroud task that posts info to this dialog was previously in

ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {                 @Override                 public void run() {                      // Background task to post logs.                    } });

But now I am not using this thread. Instead I have moved everything into a swing worker thread.

This works. But I am not totally comfortable with this. Is there any other optimistic way to accomplish this ?


Please sign in to leave a comment.