Click here to Skip to main content
15,900,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hy I've a problem about progress bar. All code right but progress bar not run. while I also pass the value one. Kindly see the solution.

What I have tried:

try
{
for (int i =0;i <=100;i++)
{
Thread.sleep (30);
sc.bar.setValue(1);
sc.progress.setText(Integer.toString(i)+"%");
}
}
catch(Exception e)
{
}
Posted
Updated 23-Jan-21 8:51am

1 solution

You are trying to update a progress bar from the thread that is processing the work: which means that the actual display can't be updated until that method exits because the thread which does the display updates is busy - sleeping and trying to update the progress bar ...

You need to move the "long running work" onto a different thread: Multithreading in Java - GeeksforGeeks[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900