Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #24144
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2013-05-21 03:22 -0700 |
| References | <6aaa6aa4-440f-44fc-8efe-a06f6603e71b@googlegroups.com> <ANygt.3001$hl7.91@newsfe14.iad> |
| Message-ID | <af1c0623-3530-4b7f-bc0a-e0169e4843cb@googlegroups.com> (permalink) |
| Subject | Re: How to send console progress information to gui |
| From | Robert Klemme <shortcutter@googlemail.com> |
On Thursday, May 2, 2013 9:05:08 PM UTC+2, Daniel Pitts wrote: > You would start a thread to read the data out of the InputStream (which > you need to do anyway to make a Process work as expected). The thread > reading the data could send an event anywhere. If you are updating a UI > thread, I suggest the following approach: > > ProgressTrackerThread.run() will read from InputStream, and when newline > happens, call "progressUpdated" on a list of Listeners. > > Create an abstract EventQueueProgressListener implementation. > progressUpdated in this impl will be final, and will pass a Runnable to > the EventQueue, which then calls a different abstract method > (handleProgressUpdated maybe?). That way, you're thread-safe on the EDT > for UI updates. There is SwingWorker for such things. http://docs.oracle.com/javase/6/docs/api/javax/swing/SwingWorker.html You still need an additional thread since there are two streams to read from (alternatively use a Selector from NIO). Kind regards robert
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to send console progress information to gui mike <mikaelpetterson@hotmail.com> - 2013-05-02 11:49 -0700
Re: How to send console progress information to gui Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-05-02 12:05 -0700
Re: How to send console progress information to gui mike <mikaelpetterson@hotmail.com> - 2013-05-07 04:50 -0700
Re: How to send console progress information to gui Robert Klemme <shortcutter@googlemail.com> - 2013-05-21 03:22 -0700
Re: How to send console progress information to gui Arne Vajhøj <arne@vajhoej.dk> - 2013-05-18 19:38 -0400
Re: How to send console progress information to gui "John B. Matthews" <nospam@nospam.invalid> - 2013-05-19 00:34 -0400
Re: How to send console progress information to gui Arne Vajhøj <arne@vajhoej.dk> - 2013-06-01 22:09 -0400
csiph-web