Swing, tail -f and threading

From: Frank D. Greco (fgreco_at_REMOVEcrossroadstechNOSPAM.com)
Date: 05/29/04


Date: Sat, 29 May 2004 11:56:46 -0400

I'm trying to capture the stdout (and stderr) of an external program
and show the output in a Swing JTextArea.

For most short-running things like 'grep', 'cat'..., its fairly
straightforward. But I'm having a little bit of difficulty with
programs that run for a long time, namely 'tail -f'.

Since 'tail -f foo' basically runs until you kill it, I'm assuming
I need to wrap my JTextArea extended component (which I call 'FileWatcher')
with a Thread/Runnable. This should allow me to instantiate a bunch of
them in a nice front end that watches a bunch of logfiles.

But I'm having problems when the objects are put into a JFrame. Nothing
is rendered properly (1.4.2)... actually the JFrame is blank. But I
get the output correctly since I also write it out to stdout in my console.

Anyone have any suggestions? Should I thread my component externally, i.e.,
in my JFrame when I instantiate my FileWatcher or should I put the thread
"inside" of it, i.e., right before I Process.exec() the external program?
I've tried both but with the same result.

Any tips or URL refs are appreciated.

Frank G.
+==========================================+
| Crossroads Technologies Inc. |
| www.CrossroadsTech dot com |
| fgreco at REMOVE!cross!roads!tech!dot!com|
+=========================================+



Relevant Pages

  • Swing, tail -f and threading
    ... I'm trying to capture the stdout of an external program ... and show the output in a Swing JTextArea. ... But I'm having problems when the objects are put into a JFrame. ... get the output correctly since I also write it out to stdout in my console. ...
    (comp.lang.java.programmer)
  • Re: Swing, tail -f and threading
    ... >> I'm trying to capture the stdout (and stderr) of an external program ... >> and show the output in a Swing JTextArea. ...
    (comp.lang.java.gui)
  • Re: Swing, tail -f and threading
    ... >> I'm trying to capture the stdout (and stderr) of an external program ... >> and show the output in a Swing JTextArea. ...
    (comp.lang.java.programmer)
  • Re: Swing, tail -f and threading
    ... > I'm trying to capture the stdout of an external program ... > and show the output in a Swing JTextArea. ... > But I'm having problems when the objects are put into a JFrame. ...
    (comp.lang.java.gui)
  • Re: Swing, tail -f and threading
    ... > I'm trying to capture the stdout of an external program ... > and show the output in a Swing JTextArea. ... > But I'm having problems when the objects are put into a JFrame. ...
    (comp.lang.java.programmer)