?? progressthread.java
字號:
package jmemorydemo;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; JLabel label; public ProgressThread(JProgressBar pbar,JLabel label) { this.pbar=pbar; this.label=label; } public void run() { /**@todo Override this java.lang.Thread method*/ int min=0; int max=100; int free=0; int totle=0; int status=0; pbar.setMinimum(min); pbar.setMaximum(max); pbar.setValue(status); while(true){ try{ totle=(int)(Runtime.getRuntime().totalMemory()/1024); free=(int)(Runtime.getRuntime().freeMemory()/1024); }catch(Exception e){ e.printStackTrace(); } label.setText("Free Memory :"+(int)(Runtime.getRuntime().freeMemory()/1024)+"K"+" Totle Memory Allocated :" +(int)(Runtime.getRuntime().totalMemory()/1024)+"K"); status=(int)(free*100/totle); pbar.setValue(status); pbar.setString("Free Momery "+ status+"%"); try{ this.sleep(1000); }catch(InterruptedException err){} } }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -