首页 > 代码库 > Java 进度条
Java 进度条
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();
}
}
}
}
}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。