|
-
April 4th, 2008, 03:49 PM
#1
Threading the GUI
Could someone please tell me how I can do this: I have a GUI class, and I have a class that does all the calculations for the program (happens to be a file decryptor). I want the GUI to start the decryption, and update a JProgressBar. Which I know how to do, HOWEVER, it causes the processing to take a very, very long time. I believe if I put the processing class in a different thread than the GUI, it will work better (is that correct?). But I don't know how to have the two threads communicate (specifically transfer the total progress from the decrypting class to the gui).
Any help?
-
April 4th, 2008, 04:30 PM
#2
Re: Threading the GUI
Read up on the Singleton design pattern. You can return the running instance of a particular class, and have that class have a method which is exposed onto it which takes a value for your progress.
-
April 4th, 2008, 06:15 PM
#3
Re: Threading the GUI
We have not seen any code. It is possible that you are doing things marveloussly wrong. Different thread for the pcroeccsing calss (whatever that means) can prove a solution, or not. What is clear, is that you should, at least have the calculations totally separe from GUI. Singleton pattern is one solution, or not, but evidently you need provide more information as to how you currently approach this issue. What your calculations are etc. From what you told us, it seems to me, that your GUI updates are diretctly dependant on your calculations, and the calculations are commenced within the same process... and that is not good. But cannot say, having seen no code.
Could be wrong in all these assumptions... but have not seen any code
Last edited by Londbrok; April 4th, 2008 at 06:18 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|