• Post Reply Bookmark Topic Watch Topic
  • New Topic

Update progress of a process in Progress bar - SWT Java GUI

 
indeewari akarawita
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my Java SWT application, I have few methods, that take longer time to complete. These methods has to be initiate and run as response to button click. There I want to implement progress bar to show the progress/status of long run method. Long run methods are Java Processes, in which it executes some command line functionality. (ex: run ls method in Linux).



In progress bar status is set using setSelection method which takes int as argument. How to indicate the progress of process in progress bar, because I don't have int value to pass into setSelection method of progressbar.

Hope my question is clear
 
Campbell Ritchie
Marshal
Posts: 52569
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you familiar with the relevant Java Tutorials section?
 
indeewari akarawita
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, That is SWING, My program running SWT. Is it fine to use swing progress bar withing SWT program?

 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
indeewari akarawita wrote:Long run methods are Java Processes, in which it executes some command line functionality. (ex: run ls method in Linux).



In progress bar status is set using setSelection method which takes int as argument. How to indicate the progress of process in progress bar, because I don't have int value to pass into setSelection method of progressbar.


Unless the Linux process itself provides some indication of 'progress' by writing to stdout or stderr there is no way to get a measure of progress to display. This applies whether one uses SWT, Swing or just Java System.out to do the display.
 
Piet Souris
Rancher
Posts: 1632
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe: if you know how long such a process takes, then you could set up a timer
and give an estimate of the progress yourself. That is, if that is possible in SWT.

Greetz,
Piet
 
indeewari akarawita
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have idea how long will it take. Does this mean there is no way of doing progress bar
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what an indefinite progress indicator is for.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!