3 Replies Latest reply: Jan 13, 2013 9:43 PM by Gowtham Gutha RSS

    JProgressBar Updation

    905538
      Hi all,

      i have to develope a swing application in which after clicking on button i have to call a user define function from another class(for example function is having the logic of weblogic domain creation) i am able to call the function but the problem is how to show a progressbar which should start at the starting of my function and show the progress of method execution and show 100% when my function get executed and return success value only(my function is returning success if task get completed successfully else return error msg)






      thanks in advance
        • 1. Re: JProgressBar Updation
          Kayaman
          You can't do that unless you know the progress of the method.
          Your alternative is to show the "undeterminate" progress bar, or show one that starts at 0%, then jumps to 100% when the method finishes.
          • 2. Re: JProgressBar Updation
            TPD-Opitz
            You can only "fake" progess by stepping forward the progess bar on a time base using a separate thread.

            bye
            TPD
            • 3. Re: JProgressBar Updation
              Gowtham Gutha
              Use Threading otherwise, at different steps of the method call update the progress value. For example,

              public void myfunction()
              {
              int i=1;
              //line1
              progressbar.setValue(i++);
              //line2
              progressbar.setValue(i++);
              //line3
              progressbar.setValue(i++);
              //line4
              progressbar.setValue(i++);
              //line5
              progressbar.setValue(i++);
              }

              or using the javax.swing.Timer class you can update the value of JProgressBar for every n milliseconds.