F
Frank D. Greco
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|
+=========================================+
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|
+=========================================+