title: How to use Progress bar such that it progress depends on the progress of a specified method?
body: <p>I am developing a GUI project which contains a <b>Method</b> for performing mysql query, connecting to various SSH Server and accessing files, say <b>Method: M1</b>.<br>
  Whenever I call method <b>M1</b> my GUI Current Dialog becomes unresponsive till the method <b>M1</b> get completed(as <b>M1</b> is very expensive method).
  <br>
  <br>
  Now instead of showing an unresponsive Dialog, I want to use a progress bar which will reflect the progress of method <b>M1</b>. There must be some way to do the same, is there?<br><br>I am using Java Swing package for developing the GUI.</p>