61162

ProgressBar using Threads in SWT

Question:

In my SWT Application i wish to use a progress bar <strong>(org.eclipse.swt.widgets.ProgressBar)</strong> i found examples but could not understand the proper flow and usage i need to perform background task for which, i was paused at the algorithm phase like i can analyze that there should be two threads one for background job, another for a progressbar both should execute simultaneously, i could not figure out the Implementation of this,i found plenty of examples but,i was puzzled where should i place my background task code <em>(still searching)</em>. Can anyone provide sample example that suits me.

Answer1:

Did you see <a href="http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet56.java" rel="nofollow">update a progress bar (from another thread)</a> from <a href="http://www.eclipse.org/swt/snippets/#progressbar" rel="nofollow">SWT ProgressBar snippets</a> page? It explains a lot.

ProgressBar have to be asynchronous to work correctly in every GUI framework. It's job is to show some value independently on main (GUI) thread. So you have to write your own thread, which will maintain the ProgressBar, resolving current value of it and show the changes of value (rendering progress by widget itself).

In Swing, you don't have to create you own thread for ProgressBar, because the class already implements upper proposed behavior (makes itself another thread and manage the work for you). But because SWT is platform dependent (and for other reasons), you have to manage this by yourself.

Recommend

  • JSP Pagination using jQuery
  • Order of selection in html select multiple?
  • Which character encoding is the IPython terminal using?
  • android: Unable to pause activity : java.lang.IllegalArgumentException: Service not registered:
  • Calling super.approveSelection() within a SwingWorker
  • RavenDB Includes still round-tripping to load included data
  • CSS Bundling and Internet Explorer's Limit
  • Putting progress bar inside edit text which will launch after user has entered something
  • Visualizing the code involved in an action?
  • Node.js: When do you know when a collection of asynchronous tasks is done?
  • Javascript fade in fade out div with youtube video
  • How to stream h264 with udp gstreamer
  • Presenting NSOpenPanel as sheet synchronously
  • maven-dependency-plugin ignores outputDirectory configuration
  • How to control Trigger state (Pause, Play) using code (not just buttons)
  • reduce/reduce conflicts using ocamlyacc
  • How to detect left mouse click but not when the click occur on a UI Button component [closed]
  • In Akka, is ActorContext thread safe?
  • Regex for nested values
  • GeoTrust SSL certificate on Android not trusted
  • How gzip file gets stored in HDFS
  • Getting NullPointer exception with File.listfiles()
  • How do I get the list of bad records that didn't load in Bigquery?
  • Is there some graphical way to create my own configuration file on SonarLint?
  • Security issues with PHP's Readfile method
  • Excel's Macro-Recorder usage
  • onBackPressed() not being executed
  • How to use carriage return with multiple line?
  • Time complexity of a program which involves multiple variables
  • one Local Olampyad Questions on Informatic in 2011
  • Could not find rake using whenever rails
  • Record samples being played with OpenAL
  • Q promise. Difference between .when and .then
  • Spray.io: When (not) to use non-blocking route handling?
  • what is the difference between the asp.net mvc application and asp.net web application
  • Weird JavaScript statement, what does it mean?
  • Delete MySQLi record without showing the id in the URL
  • Transpose CSV data with awk (pivot transformation)
  • need help with bizarre java.net.HttpURLConnection behavior
  • Programmatically clearing map cache