progressthread.java~7~
来自「这是各类实用工具的源码100例」· JAVA~7~ 代码 · 共 55 行
JAVA~7~
55 行
package jthreadrace;import javax.swing.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class ProgressThread extends Thread { JProgressBar pbar;// boolean stopped; public ProgressThread(JProgressBar pbar,int priority) { try{ this.pbar=pbar;// this.stopped=false; this.setPriority(priority); }catch(Exception err){ err.printStackTrace(); } }// void setStop(boolean state){// this.stopped=state;// } public void run() { /**@todo Override this java.lang.Thread method*/ int min=0; int max=100; this.pbar.setMinimum(min); this.pbar.setMaximum(max); this.pbar.setValue(min); for(int i=min; i<=max; i++){// if(stopped)// break;// else{ this.pbar.setValue(i); try{ Thread.sleep(50); }catch(Exception err){ err.printStackTrace(); }// } } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?