2018年05月23日(星期三)  农历:戊戌年四月初九

作者:三年。分类: JAVA

java swing 之进度条的使用

* @author zengto

*/

package com.zengto;

import java.awt.FlowLayout;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.JProgressBar;

import javax.swing.border.EmptyBorder;

public class JProgressBarDemo extends JFrame {

public JProgressBarDemo(){

this.setTitle("进度条的使用");

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setBounds(100, 100, 250, 100);

JPanel contentPane=new JPanel();

contentPane.setBorder(new EmptyBorder(5,5,5,5));

this.setContentPane(contentPane);

contentPane.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));

final JProgressBar progressBar=new JProgressBar();

progressBar.setStringPainted(true);

new Thread(){

public void run(){

for(int i=0;i<=100;i++){

try{

Thread.sleep(100);

}catch(InterruptedException e){

e.printStackTrace();

}

progressBar.setValue(i);

}

progressBar.setString("升级完成!");

}

}.start();

contentPane.add(progressBar);

this.setVisible(true);

}

public static void main(String[]args){

JProgressBarDemo example=new JProgressBarDemo();

}

}

温馨提示如有转载或引用以上内容之必要,敬请将本文链接作为出处标注,谢谢合作!

已有 0/772 人参与

发表评论:



手Q扫描加入Java初学者群