I have a client server program where the client is requesting a (jasper)report from server and displays it on screen. The report-fetching part is handled by Swingworker on client side as the report might take a while to arrive (server running query against a DB etc.).
Below is my SwingWorker code:
class ReportFetcher extends SwingWorker<JasperPrint, Void> {
private String reportName;
public ReportFetcher (String reportName) {
this.reportName = reportName;
}
@Override
protected JasperPrint doInBackground() {
SocketClient client = new SocketClient(serverAddress, 9999);
client.sendSignal("Report-" + reportName);
JasperPrint print = null;
try {
print = client.getReport();
System.out.println("Report fetched : " + reportName);
} catch (Exception ex) {
...
}
client.close();
return print;
}
@Override
protected void done() {
JasperViewer jv = null;
try {
jv = new JasperViewer(get(), false);
} catch (Exception e) {
...
}
if (jv != null) {
jv.setTitle(reportName);
...
jv.setVisible(true);
}
}
}
In the code above the whole time-consuming code on client side is just a single method call : print = client.getReport();
So would it possible at all to use a progress bar in this case ? (ie since there are no intermediate signs of progress) ? Any suggestions ?