Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextArea not updateing  RSS feed

 
Nate Lockwood
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the user clicks on a particular component on my GUI a listener dispatches the code below which, in turn, executes a method that creates a system process to update the computer clock with network time servers.



LinxSUSO.syncClockDebug() contains this code (and more of course) and the command it runs is "sudo /usr/sbin/ntpdate":


My problem that the first comment written to the log (JTextArea) is not written until LinuxSUDO.syncClockDebug(); returns and it doesn't return until the the Process p completes. In the development environment this takes about 10 seconds but the user has no feedback that the mouse click worked - and that violates one of my top principles of user interactions; always provide feedback.

How can I get the JTextArea to update immediately after the comment is wrtten to it?


 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the tutorial: Lesson: Concurrency in Swing.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't forget When Runtime.exec() won't.
 
Nate Lockwood
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Rob and Paul, my use of runtime() is up to mediocre!

I have code that works - except - I'd like to get a string back from the process to display difference it time that was found if the sync works and the error message if it doesn't I couldn't follow all from the Oracle reference. Here's what I'm using now. (edit: a couple of typos)

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!