i use DynamicReports
library for make reports for my app. Createing report takes some time and i decided create custom progress bar while reports has not been created. Question after code examples.
progress bar class:
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();
}
}
Report abstract class
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();
}
Question: when i create ProgressDialog, program flow stops while i do not close dialog. Why it's happen, how this behaviour called and where i can read about it? How it use and маке it work for me. Thanks.
I believe your problem is that you are not creating a new thread for your progress dialog. Here is an example that will help you. Modal Progress Dialog example