2013-03-27 30 views
1

我們知道jasper查看器需要很多時間根據將要顯示的數據來處理報告。 我想處理它,給用戶加載信息。 這是我的步驟:我如何檢測JasperViewer處理報告時間

  1. 檢查,是查看器正在處理還是完成。
  2. 如果在過程中,創建一個JLabel並設置文本爲「加載報表...」
  3. 如果完成,將文本設置爲「」或零

而且點1,我不知道如何檢查查看器是否在生成過程中? 請幫幫我。謝謝:)

回答

0

撥打viewReport()在一個單獨的線程。存儲實例級別AtomicBoolean,並在報告完成後將其設置爲false。在您的客戶端檢查方法中,定期檢查此實例變量以檢查報告是否完成。

實施例的僞代碼:

public void YourClass { 

private AtomicBoolean reportRunning; 

... 

private void getReport() { 

    new Thread() { 

    reportRunning = new AtomicBoolean(true); 
    JRViewer.viewReport(); 
    reportRunning.set(false); 

    }.start(); 

} 

// Call periodically and update UI  
private boolean clientCheck() { 

    return reportRunning != null && reportRunning.get(); 

}