gpt4 book ai didi

java - 我如何检测 JasperViewer 处理报告时间

转载 作者:行者123 更新时间:2023-12-01 04:47:03 24 4
gpt4 key购买 nike

我们知道 Jasper Viewer 需要很多时间来根据将要显示的数据来处理报告。我想处理它,并向用户提供加载信息。这是我的步骤:

  1. 检查查看器是否正在处理或已完成。
  2. 如果正在处理中,请创建 JLabel 并将文本设置为“正在加载报告...”
  3. 如果完成,请将文本设置为“”或 null

还有点1,我不知道如何检查查看器是否正在生成过程中?请帮我。谢谢:)

最佳答案

在单独的线程中调用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();

}

关于java - 我如何检测 JasperViewer 处理报告时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15651648/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com