troubleshooting Question

Refresh poblem with JProgressBar

Avatar of davidnewmanuk
davidnewmanuk asked on
Java
21 Comments2 Solutions1415 ViewsLast Modified:
Trying to make a JProgressBar work, problem is that it does not display the value of progress until code has completed.  its setting the value but becuase code is still running it wont update until the last line of code is exectued. is there a way to refresh the screen of the main form to reflect the actual value of the progress bar, thanks

method in main form:

    public void setProgressStatus(int value, String action){
        progVal = progVal + value;
        lblProgress.setText(action);
        progressBar.setValue(progVal);
        if (value >1000){
            Toolkit.getDefaultToolkit().beep();
            timer.stop();
            //startButton.setEnabled(true);
            setCursor(null); //turn off the wait cursor
            progressBar.setValue(progressBar.getMinimum());            
        }
        this.repaint();
    }

code from another class (has reference to main form)

         psForm.setProgressStatus(10, "deleteing table");
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 21 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros