ProgressMonitor进度条的问题

greenbar 2009-11-03 02:42:54

public class UploadActionListener implements ActionListener {

private String path;
1. private ClientFrame clientFrame;
private Socket clientSocket;
private OutputStream os;
private BufferedOutputStream bos;
private DataOutputStream dos;
private InputStream is;
private BufferedInputStream bis;
private DataInputStream dis;
//进度条
2. private ProgressMonitor pm;

3. public UploadActionListener(String path,ClientFrame clientFrame,Socket clientSocket,
OutputStream os,BufferedOutputStream bos,DataOutputStream dos,
InputStream is,BufferedInputStream bis,DataInputStream dis){
this.path = path;
this.clientFrame = clientFrame;
this.clientSocket = clientSocket;
this.os = os;
this.bos = bos;
this.dos = dos;
this.is = is;
this.bis = bis;
this.dis = dis;
}
public void actionPerformed(ActionEvent arg0) {
try {
File file = new File(path);
System.out.println("上传文件为:" + path);

4. pm = new ProgressMonitor(clientFrame,"Monitoring Progress","Test",0,100);

5. pm.setProgress(0);
6. pm.setMillisToPopup(1000);
断点 for(int h = 0;h<=100;h++){
7. pm.setProgress(h);
}

//获取文件后缀名
int str = path.lastIndexOf(".");
String ext = path.substring(str + 1, path.length());

//向服务器端发送文件后缀名
dos.writeUTF(ext);
dos.flush();

//本地文件输入输出流
FileInputStream fis = new FileInputStream(file);
BufferedInputStream bis1 = new BufferedInputStream(fis);

byte [] buffer = new byte[10240];
int i = -1;
while((i = bis1.read(buffer)) > 0){
dos.write(buffer,0,i);

System.out.println("333333333");
dos.flush();
}
System.out.println("文件上传完毕");
bis1.close();
fis.close();
dos.close();
bos.close();
os.close();
dis.close();
bis.close();
is.close();
clientSocket.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}

其他的都不用看 只要看有关进度框的,clientFrame是一个JFrame的类,与进度框有关的我都标记出来了
我也不太知道哪些方法的大体意思,第一次看,按照资料上面写的
我设置的断点,一步一步做的,进度框出来了,就一个框框,里面什么都没,好像卡住了
为什么?
...全文
215 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hao234ksdf 2009-11-24
  • 打赏
  • 举报
回复
这个简单,用邮箱发给你吧!
lz12366007 2009-11-03
  • 打赏
  • 举报
回复
贴出所有的代码吧,否则没法看。。。
greenbar 2009-11-03
  • 打赏
  • 举报
回复
没人知道吗?

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧