• 进度条


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

  • 相关阅读:
    进程、线程、线程安全理解
    查日志常用Linux命令
    Spring容器管理Bean的生命周期
    在Linux模拟浏览器访问下载文件
    在windows上安装mysql
    java判断ip和端口是否通信正常
    Mongodb开启慢查询
    golang 中奇怪的空切片
    关于 MySQL sql_log_bin
    MySQL read_only 与 super_read_only 之间的关系
  • 原文地址:https://www.cnblogs.com/qiqisx/p/7652045.html
Copyright © 2020-2023  润新知