我无法更新进度条…这是我的代码
Thread t=new Thread(new Runnable(){ public void run(){ int i=1; jProgBar.setMinimum(0); jProgBar.setMaximum(100); try { while(i<=100 || true){ jProgBar.setValue(i); i++; Thread.sleep(50); } } catch (InterruptedException ex){ jProgBar.setValue(jProgBar.getMaximum()); } } }); t.start(); .... Something code that correctly works t.interrupt();
进度栏状态仅在线程末尾更新。有人能帮我吗??
谢谢大家 我这样解决了
try{ jProgBar.setIndeterminate(true); jProgBar.setStringPainted(true); jProgBar.setBorderPainted(true); new Thread(new Runnable() { public void run() { ... // here is code that i've to wait // after this i stop my jProgressBar ... jProgBar.setStringPainted(false); jProgBar.setBorderPainted(true); jProgBar.setIndeterminate(false); } }).start(); } catch(IllegalStateException ex){ //some code }