用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

进度条2

2019-05-09 作者: 羁绊举报

[java]代码库

package wang1;


import java.awt.EventQueue;
import java.awt.Toolkit;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollBar;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
 
 
import javax.swing.JProgressBar;
import javax.swing.JLabel;
import java.awt.Color;
 
public class JProcessBar  extends JFrame {
 
    // 得到显示器屏幕的宽高
    public static int width = Toolkit.getDefaultToolkit().getScreenSize().width;
    public static int height = Toolkit.getDefaultToolkit().getScreenSize().height;
    // 定义窗体的宽高
    public static int windowsWedth = 600;
    public static int windowsHeight = 600;
 
    private static final long serialVersionUID = 1L;
 
    private JProgressBar progressBar = new JProgressBar();
 
 
    private boolean state = false;
    private int count = 0;
 
    // 工作线程workThead
    private Thread workThead = null;
    private Runnable run = null;
 
     
    public static void main(String[] args) {
 
        JProcessBar jp = new JProcessBar();
        jp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jp.setVisible(true);
    }
 
    /**
     * Create the application.
     */
    public JProcessBar() {
         
        initialize();
    }
JLabel lblNewLabel_1 = new JLabel("");
    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        this.setTitle("\u52A0\u8F7D\u4E2D");
        this.setBounds((width - windowsWedth) / 2, (height - windowsHeight) / 2, 545, 186);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.getContentPane().setLayout(null);
        progressBar.setForeground(Color.BLACK);
        progressBar.setStringPainted(true);
        progressBar.setOpaque(false);
        progressBar.setBounds(73, 103, 434, 24);
        this.getContentPane().add(progressBar);
         
        JLabel lblNewLabel = new JLabel("\u8FDB\u5EA6\u52A0\u8F7D\uFF1A");
        lblNewLabel.setBounds(10, 106, 68, 15);
        this.getContentPane().add(lblNewLabel);
        lblNewLabel_1.setOpaque(true);
        lblNewLabel_1.setBounds(73, 80, 235, 24);
        getContentPane().add(lblNewLabel_1);
         
        if (workThead == null) {
            state = true;
            workThead = new WorkThead();
            workThead.start();
        }
    }
    class WorkThead extends Thread {
 
        public void run() {
 
            while (count < 100) {
 
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
 
                if (state) {
                    count++;
                    SwingUtilities.invokeLater(new Runnable() {
 
                        @Override
                        public void run() {
                            // TODO Auto-generated method stub
                            // 更新操作通过事件派发线程完成(一般实现Runnable()接口)
                            progressBar.setValue(count);
                            if(count==5){
                            lblNewLabel_1.setText("loading api-ms-win-core-xstate-l1-1-0.dll");
                            }else if(count==10){
                                lblNewLabel_1.setText("loading MaxxAudioAPO5064.dll");
                            }else if(count==20){
                                lblNewLabel_1.setText("loading MetroIntelGenericUIFramework.dll");
                            }else if(count==30){
                                lblNewLabel_1.setText("loading microsoft-windows-kernel-power-events.dll");
                            }else if(count==40){
                                lblNewLabel_1.setText("miguiresource.dll");
                            }else if(count==80){
                                lblNewLabel_1.setText("loading mfvdsp.dll");
                            }else if(count==90){
                                lblNewLabel_1.setText("loading miguiresource.dll");
                            }else if(count==100){
                                lblNewLabel_1.setText("loading end");
                                Thread.currentThread();
								try {
									Thread.sleep(500);
								} catch (InterruptedException e) {
									// TODO 自动生成的 catch 块
									e.printStackTrace();
								}
                             
                            }
                        }
                    });
                }
            }
        }
 
    }
}


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...