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.
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
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 firstname.lastname@example.org
Joined: Dec 04, 2001
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