我使用DynamicReports
库为我的应用程序制作报告。创建报告需要一些时间,我决定在尚未创建报告时创建自定义进度条。代码示例后的问题。
进度条类:
public class ProgressDialog implements DialogWrapper{
private JFrame iFrame;
private JDialog iDialog;
private JPanel pane;
private final JProgressBar aJProgressBar = new JProgressBar(0, 100);
public ProgressDialog(){
onCreate();
}
@Override
public void onCreate() {
iFrame = new JFrame("Создание отчета");
iDialog = new JDialog(iFrame, true);
pane = new JPanel();
aJProgressBar.setIndeterminate(true);
pane.add(aJProgressBar, BorderLayout.NORTH);
iDialog.add(pane, BorderLayout.CENTER);
iDialog.setTitle("Создание отчета");
iDialog.setSize(300, 150);
iDialog.setResizable(false);
iDialog.setVisible(true);
return;
}
@Override
public void fillData() {}
@Override
public void onSubmit() {}
protected void onCancel(){
iDialog.setVisible(false);
iDialog.dispose();
}
public void cancel(){
onCancel();
}
}
报表抽象类
public abstract class AbstractReportMain<T extends ReportDesign<U>, U extends ReportData> {
private ProgressDialog pd;
public AbstractReportMain() {
pd = new ProgressDialog();
build();
}
protected void build() {
try {
JasperReportBuilder reportBuilder = DynamicReports.report();
U data = getReportData();
if (data != null) {
reportBuilder.setDataSource(data.createDataSource());
}
getReportDesign().configureReport(reportBuilder, data);
pd.cancel();
reportBuilder.show(false);
} catch (DRException e) {
e.printStackTrace();
}
}
protected U getReportData() {
return null;
}
protected abstract T getReportDesign();
}
问题:当我创建 ProgressDialog 时,程序流在我不关闭对话框时停止。为什么会发生这种情况,这种行为是如何被调用的,我在哪里可以读到它?它是如何使用和使它对我有用的。谢谢。