This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Updation of ProgressBar?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Updation of ProgressBar??" Watch "Updation of ProgressBar??" New topic
Author

Updation of ProgressBar??

Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi all friends,
Iam facing problem with updation of progressBar of my swing Interface.I want to update my progressBar by the bytes which is already written by server on destination.It is basically a uploading software.For that iam using a thread and i have written a method of taking the bytes from servlet.And in servlet iam writting bytes by 'PrintWriter' in loop.But I couldn't update progressBar.Can any one plz guide me where i am wrong in my code.If possible plz give me some code for that.Iam pasting those portion of codes only.Eagerly waiting for someone reply.

Regards
Bikash
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
The problem is that swing components are not thread safe. You should never change the state of a swing component except in the swing dispatcher thread. You can use a javax.swing.Timer to do it like this:

Moving this to the Swing forum.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Viswa Laksh
Greenhorn

Joined: Apr 30, 2003
Posts: 9
I think this code snippet would help you. Try this..
Code for downloading and updating progress bar. "FileRecv" is the calling program and progress bar is declared as static.

Calling code from "FileRecv" Program.

~Viswa
Mallick Choppa
Greenhorn

Joined: May 23, 2003
Posts: 9
Hi,
I think its not related to swing or any thing else. See when u are receiving by using "BufferInputStream" actually all the data gets buffered until it is full only then it is read out of the buffer. So you just need to add
"out.flush();" on ther server code as below.
os.write(buf, 0, cc);
tot += cc;
out.println(tot);
out.flush(); //this u need to this.
if (str.equals(str1)) break;
Hope this works, if you want any thing about this u can mail to my id below.
Mallick
mallick@orillion.stph.net
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi all friends,
I have tried as per Michael Morris and Mallick Choppa suggestion I have add Updater class in my swing interface code and also add out.flush(); in my servlet code.But I couldn't slove my problem.Now my server stop writting file after wrtting some portion of file on remote destination and no progressBar activity.And my swing interface going to hang.Iam explaining once again i want to update my progressBar when server writting file on destination.I can show the progress of reading file by my swing interface but i want to show the progress of writting of file.Now Iam pasting code of my method through Iam uploading file:-

My checkForFilesToUpload method check my hot folder every after 30 second for files and take the file in listFiles() in array of file and by sorting files by size it strats uploading of smallest file using my doPost method one by one from queue thats why i have called my doPost method inside checkForFilesToUpload method.Can any plz guide me where iam wrong in my swing interface or in servlet.
Regards
Bikash
 
 
subject: Updation of ProgressBar??
 
Similar Threads
Writting confirmation message??
Updation of ProgressBar??
Updation of ProgressBar??
skip() method of InputStream???
Connection Broken & Check??