码迷,mamicode.com
首页 > 其他好文 > 详细

进度条

时间:2017-10-11 19:18:52      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:err   tcl   ati   ogre   val   set   数值   private   print   

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();
}
}

进度条

标签:err   tcl   ati   ogre   val   set   数值   private   print   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!