首页 > 其他 > 详细

进度条

时间:2017-10-11 18:36:25      阅读:278      评论:0      收藏:0      [点我收藏+]

import java.awt.Color;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.JPanel;

public class Jindu {

private JFrame frame;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Jindu window = new Jindu();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the application.
*/
public Jindu() {
initialize();
}

/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JProgressBar a= new JProgressBar();
a.setStringPainted(true);
JPanel panel = new JPanel();
a.setBackground(Color.GREEN);
panel.setBounds(49, 119, 375, 116);
frame.getContentPane().add(panel);
panel.add(a);
new Thread(){

public void run(){
for (int i = 0; i <= 100; i++) {
try {
Thread.sleep(100); // 让当前线程休眠0.1ms
} catch (InterruptedException e) {
// TODO: handle exception
e.printStackTrace();
} a.setValue(i); // 设置进度条数值

}
a.setString("创建成功");// 设置提示信息
}
}.start();
}
}

进度条

原文:http://www.cnblogs.com/qiqisx/p/7652045.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!