码迷,mamicode.com
首页 > 编程语言 > 详细

Java 进度条

时间:2014-08-09 18:24:38      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:style   color   java   os   io   strong   for   art   

public class jprogess3s extends JFrame {
 
       public static   JPanel contentPane;
       private static JProgressBar progressBar;
      
       public static JLabel picture;
       public jprogess3s() throws InterruptedException {
            setTitle( "Drawing");
            setDefaultCloseOperation(JFrame. HIDE_ON_CLOSE);
            setBounds(100, 100, 464, 98);
             contentPane = new JPanel();
             contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
            setContentPane( contentPane);
             contentPane.setLayout(null);
            JPanel panel = new JPanel();
            panel.setBounds(5, 5, 433, 52);
             contentPane.add(panel);
            panel.setLayout( null);
             progressBar = new JProgressBar(0,300);
             progressBar.setBounds(10, 5, 406, 36);
             progressBar.setStringPainted(true);
            panel.add( progressBar);
            setLocationRelativeTo( null);
             this.setVisible(true);
            
            Thread t = new Thread(new thread1());
            t.start();
            
            
      }
  public static class thread1 implements Runnable{
               
 
                   public void run()
                {
                        
                        for (int i=0; i<=3; i++)
                        {
                               //Progressively increment variable i
                               progressBar.setValue(i*100); //Set value
                               progressBar.repaint(); //Refresh graphics
                               try {
                                          Thread. sleep(1000);
                                    } catch (InterruptedException e) {
                                           // TODO Auto-generated catch block
                                          e.printStackTrace();
                                    }
                        }
    }
      }
}
      

Java 进度条,布布扣,bubuko.com

Java 进度条

标签:style   color   java   os   io   strong   for   art   

原文地址:http://www.cnblogs.com/csytangresearch/p/3901254.html

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