久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

java調(diào)用進(jìn)度條案例

 oneseral 2012-07-27

import java.awt.BorderLayout; 
import java.awt.GridBagConstraints; 
import java.awt.GridBagLayout; 
import java.awt.event.ActionEvent; 
import java.awt.event.ActionListener;

import javax.swing.JButton; 
import javax.swing.JFrame; 
import javax.swing.JPanel; 
/**
 * 進(jìn)度條窗體界面設(shè)計
 * @author dell
 *
 */
public class ProgressFrame extends JFrame { 
 
 JPanel panel1;
 JButton button1;
 GridBagConstraints gridBagConstraints1;
 
 ProgressPane progresspane; 
 
 public ProgressFrame() { 
  super(); 
  setTitle("進(jìn)度條"); 
  setBounds(100, 100, 500, 120); 
  setLayout(new BorderLayout()); 
  
  printFrame();
  this.setVisible(true);
  this.setResizable(false);
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
 } 
 
 public void printFrame(){
  progresspane = new ProgressPane(); 
  
  button1 = new JButton("隱藏"); 
  panel1 = new JPanel(); 
  panel1.setLayout(new GridBagLayout()); 
  
  gridBagConstraints1 = new GridBagConstraints(); 
  gridBagConstraints1.gridy = 0; 
  gridBagConstraints1.gridx = 0; 
  
  panel1.add(button1, gridBagConstraints1); 
  
  getContentPane().add(panel1, BorderLayout.CENTER); 
  getContentPane().add(progresspane, BorderLayout.NORTH);

//  事件監(jiān)聽 
  button1.addActionListener(new ActionListener() { 
   public void actionPerformed(final ActionEvent e) { 
    hide();
   } 
  }); 
 }
}


import java.awt.GridBagConstraints; 
import java.awt.GridBagLayout; 
import java.awt.Insets; 
import javax.swing.JLabel; 
import javax.swing.JPanel; 
import javax.swing.JProgressBar;

/**
 * Java進(jìn)度條
 * @author dell
 *
 */
public class ProgressPane extends JPanel{

 public JLabel label; 
 public JProgressBar progressBar;

 public ProgressPane() { 
  super(); 
  setLayout(new GridBagLayout()); 
  setSize(394, 33);

  progressBar = new JProgressBar(0,100); 
  progressBar.setStringPainted(true); 
  final GridBagConstraints gridBagConstraints = new GridBagConstraints(); 
  gridBagConstraints.weightx = 1.0; 
  gridBagConstraints.ipady = 1; //進(jìn)度條的寬度
  gridBagConstraints.fill = GridBagConstraints.BOTH; 
  gridBagConstraints.weighty = 1.0; 
  gridBagConstraints.gridx = 0; 
  gridBagConstraints.gridy = 0; 
  gridBagConstraints.ipadx = 75; 
  gridBagConstraints.insets = new Insets(4, 0, 0, 0); 
  add(progressBar, gridBagConstraints);


  label = new JLabel(); 
  final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints(); 
  add(label, gridBagConstraints_1); 
  label.setText("進(jìn)度顯示"); 
  
  gridBagConstraints_1.gridx = 1; 
  gridBagConstraints_1.gridy = 0; 
  gridBagConstraints_1.ipadx = 54; 
  gridBagConstraints_1.insets = new Insets(0, 12, 10, 0); 
 }

/**
 * 提取使用過程
 * @author shk
 *
 */
public class UseProgress{

    ProgressFrame progress;
    
    public UseProgress(){
        progress=new ProgressFrame();
    }
    
    public void printProgress(String msg,int num){
        progress.progresspane.progressBar.setValue(num); 
        progress.progresspane.progressBar.setString(msg+num+"%"); 
    }
}


 /**
 * 測試類
 * @author SHK
 *
 */
public class Test {

 public static void main(String[] args) {
  new Test().test();
 }
 
 public void test(){
  UseProgress use=new UseProgress();
  for(int i=0;i< =100;i++){ 
   use.printProgress("正在上傳文件...     ",i);
   try {
    Thread.sleep(100);
   } catch (InterruptedException e) {
    e.printStackTrace();
   }
  } 
  use.progress.hide();//隱藏進(jìn)度條
 }
 
}

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多