我的进度条仅更新为100%。我检查打印,似乎一切都应该运行,但UI不会根据打印检查中的参数更新!
这是我的Panel类。主类创建框架添加我创建的MyPanel:
objcmd.Parameters.Add(new SqlParameter("@DATA_REGISTRO", Convert.ToDateTime(param_date).Date));
答案 0 :(得分:1)
此外,我发现swingworker的java文档非常有用,可以理解它是如何工作的。例子很简单但很好解释。 https://docs.oracle.com/javase/8/docs/api/javax/swing/SwingWorker.html
// use this code inside actionPerformed()
new SwingWorker(){
@Override
protected Object doInBackground() throws Exception {
// all your code goes here
for( ; currentFolder < DFLIST.length ; currentFolder++){
double f = currentFolder + 1;
double t = DFLIST.length;
double currentPercentInDouble = (f / t);
int currentPercent = (int) (currentPercentInDouble * 100);
// send the current progress to progress bar. This needs to be updated to progress bar in process() method
publish(currentPercent)
}
// rest of the code
}
@Override
protected void process(List<V> chunks) {
// update the progress bar here
}
}.execute();