java中使用进度条为何不能更新进度条?
java进度条显示下载进度,我在每写一次数据时都setValue(setValue);但进度条到下载完后一次完成显示,而不是每次显示进度,请高手帮我看一下问题出在哪里?
代码如下:
FileLoad.java:
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class FileLoad extends JFrame implements ActionListener
{
JPanel norJp=new JPanel();
JPanel souJp=new JPanel();
JLabel addLabel=new JLabel( "下载地址: ");
JTextField jtf=new JTextField(20);
JButton jb=new JButton( "下载 ");
JProgressBar jpb=new JProgressBar(0,0,500);
public static void main(String[] args)
{
new FileLoad();
}
public FileLoad()
{
this.setTitle( "FileLoad ");
this.setSize(500,200);
Container con=super.getContentPane();
BorderLayout border=new BorderLayout();
con.setLayout(border);
jb.addActionListener(this);
norJp.setLayout(new FlowLayout());
norJp.add(addLabel);
norJp.add(jtf);
norJp.add(jb);
souJp.setLayout(new FlowLayout());
jpb.setValue(50);
souJp.add(jpb);
con.add(norJp,BorderLayout.NORTH);
con.add(souJp,BorderLayout.CENTER);
this.show();
}
public void actionPerformed(ActionEvent e)
{
//System.out.println( "++++++++ ");
int i=0;
int value=10;