我需要制作一个通用SwingWorker
进程才能在我的所有程序中使用它。
我的班级是这样的:
public class LoadingSwingWorker extends SwingWorker<Integer, Integer> {
private WaitingDiag diag;
private Statistics st = new Statistics();
public LoadingSwingWorker(GraphEditor editor, Statistics st) { //st variable
this.st = st;
Window mainWindow = SwingUtilities.windowForComponent(editor
.getGraphComponent().getParent());
diag = new WaitingDiag(mainWindow, "Loading data...");
}
@Override
protected Integer doInBackground() throws Exception {
st.loadInitialData(); //st method
return 42;
}
@Override
protected void done() {
diag.dispose();
}
public void openDiag() {
diag.setVisible(true);
}
}
对于我的所有程序,我可能需要创建SwingWorker
类和我需要的long_time任务(在这种情况下为st
变量),是不可能的实现通用的