有那位大侠有用swing控件结合 线程 来做应用程序的范例,比如进度条什么的???
swing控件结合 线程 来做应用程序的范例,比如进度条什么的??? 问题点数:50、回复次数:2Top
1 楼juhwali(华仔)回复于 2003-06-04 18:19:51 得分 0
我的是下载进度显示,挺简单的呀。Top
2 楼juhwali(华仔)回复于 2003-06-04 18:22:10 得分 50
哪里有困难吗?
try{
Thread thread = new Thread(new Runnable(){
public void run(){
try{
File file = new File(fileName);
fileLength = file.length();
notifier.setTotalLength(fileLength);
status.setText("uploading...");
notifier.setStatusLabel(status);
FTPClient ftpClient = new FTPClient(remoteServer, remotePort);
ftpClient.setNotifier(notifier);
ftpClient.login(user, password);
ftpClient.chdir(remotePath);
ftpClient.setType(FTPTransferType.BINARY);
FileInputStream inputStream = new FileInputStream(fileName);
ftpClient.put(inputStream, remoteFile);
ftpClient.quit();
status.setText("success");
// uploadButton.setEnabled(true);
}catch(Exception ex){
ex.printStackTrace();
fileLength = 0;
status.setText("Failed");
}
}
});
uploadButton.setEnabled(false);
thread.start();
}catch(Exception ex){
ex.printStackTrace();
}
Top




