Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Updating Swing Display Regulary in Background
I think this would be setup with Thread, but I'm posting it with the idea
that there might be a better way, or something I'm unaware of that might
work better.

I have a Swing app that creates a number of files in a directory and later
prints them out.  In the app window, I want to be able to keep an updated
count of how many files are in the directory, waiting to be printed.  The
best way I know of to do this is to use Thread and create a small thread
that is essentially a While loop.  Inside the loop, I count the files in
the directory, then sleep for a few seconds, then repeat.  I'd start this
thread once the GUI is complete and visible.

Is this pretty much the "best" way (recognizing that "best" is a relative
term) to do this, or are there other ways that are recommended?

Thanks!

Hal

Report this thread to moderator Post Follow-up to this message
Old Post
Hal Vaughan
09-21-04 08:59 PM


Re: Updating Swing Display Regulary in Background
Hal Vaughan wrote:
> I think this would be setup with Thread, but I'm posting it with the idea
> that there might be a better way, or something I'm unaware of that might
> work better.
>
> I have a Swing app that creates a number of files in a directory and later
> prints them out.  In the app window, I want to be able to keep an updated
> count of how many files are in the directory, waiting to be printed.  The
> best way I know of to do this is to use Thread and create a small thread
> that is essentially a While loop.  Inside the loop, I count the files in
> the directory, then sleep for a few seconds, then repeat.  I'd start this
> thread once the GUI is complete and visible.
>
> Is this pretty much the "best" way (recognizing that "best" is a relative
> term) to do this, or are there other ways that are recommended?

It's probably better to have your "working" thread
update the GUI each time it finishes a file, using
SwingUtilities.invokeLater().

--
Eric.Sosman@sun.com


Report this thread to moderator Post Follow-up to this message
Old Post
Eric Sosman
09-21-04 08:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:15 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.