• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTextArea not updateing

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?


 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read the tutorial: Lesson: Concurrency in Swing.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)

 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic