• 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

Updation of ProgressBar??

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic