i have two different classes into two different files One class is for ProgressBar
public class ProgressBarController implements Initializable {
@FXML
public ProgressBar progressBar;
@Override
public void initialize(URL location, ResourceBundle resources) {
}
}
and another class is where i want to loop through the list and want to update the progress on the basis of that list
public class AnotherClass {
public Envelope function(List<Invoice> invoiceList) throws IOException {
for(Invoice invoiceModel : invoiceList) {
// update the progressBar and do some work
}
}
}
I tried to create a new thread
Task<Void> task = new Task<>() {
@Override
public Void call() {
for (int i = 0; i < 100; i++) {
// do some work
updateProgress(i + 1, 100);
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return null;
}
};
progressBar.progressProperty().bind(task.progressProperty());
Thread thread = new Thread(task);
thread.start();
but this was not working either my progress bar is not updating and if it is then it is updating after complete all other task.
I want to update the progressBar on the basis of data in for loop.