相关疑难解决方法(0)

如果线程启动执行程序,则无法从Future <?>和SwingWorker获取ArrayIndexOutOfBoundsException

我通过使用Executor玩SwingWorker的多线程,我在那里错误地从Vector中识别出错误的元素,看起来像这个代码相当忽略了Vector中的元素不存在

我的问题 - >如何/有可能以某种方式捕获此异常

简单的输出

run:
Thread Status with Name :StartShedule, SwingWorker Status is STARTED
Thread Status with Name :StartShedule, SwingWorker Status is DONE
Thread Status with Name :StartShedule, SwingWorker Status is STARTED
Thread Status with Name :StartShedule, SwingWorker Status is DONE
Thread Status with Name :StartShedule, SwingWorker Status is STARTED
Thread Status with Name :StartShedule, SwingWorker Status is DONE
BUILD SUCCESSFUL (total time: 11 seconds)
Run Code Online (Sandbox Code Playgroud)

通过取消注释

//changeTableValues1(); // un-comment for get ArrayIndexOutOfBoundsException
Run Code Online (Sandbox Code Playgroud)

一切都正确,我得到ArrayIndexOutOfBoundsException并输出

run:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: …
Run Code Online (Sandbox Code Playgroud)

java swing exception-handling vector swingworker

20
推荐指数
2
解决办法
8356
查看次数

Swing中的Java任务进度条

我需要一个非常简单的(骨架)教程,用于在Java中开发GUI的进度条.进度条可以是"不确定的",理想情况下具有可更新的文本标签.

这是一些骨架代码,我希望有人可以扩展到足以让某些东西发挥作用.

class MyFunView extends FrameView {

  // class vars and other stuff...

  @Action
  public void excitingButtonPressed() {

     /* I have n files to download */
     // Download file 1, set progress bar status to "downloading file 1"
     // ...
     // Download file n, set progress bar status to "downloading file 2"

  }

} 
Run Code Online (Sandbox Code Playgroud)

基本上,我如何以及如何包装下载代码?(我知道有一些Task的子类需要吗?)

非常感谢提前.

编辑:

我们都只有很多宝贵的时间活着,没有任何方法可以按照我希望的那么少的代码或时间来完成,所以我不会使用进度条.

java swing jprogressbar

3
推荐指数
1
解决办法
5178
查看次数