我已經實現了SWT嚮導應用程序,在此應用程序中,我以編程方式執行解壓縮文件,並且在解壓縮期間需要一個進度條。如果您使用的是JFace的Wizard
,你可以使用內置的進度監視器中,請找到解壓下面的代碼,需要在SWT嚮導中解壓縮時的進度條由java
public static void extract(File zipfile, File outdir)
{
try
{
ZipInputStream zin = new ZipInputStream(new FileInputStream (zipfile));
ZipEntry entry;
String name, dir;
while ((entry = zin.getNextEntry()) != null)
{
name = entry.getName();
if(entry.isDirectory())
{
mkdirs(outdir,name);
continue;
}
/* this part is necessary because file entry can come before
* directory entry where is file located
* i.e.:
* /foo/foo.txt
* /foo/
*/
dir = dirpart(name);
if(dir != null)
mkdirs(outdir,dir);
extractFile(zin, outdir, name);
}
zin.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
在嚮導頁中我把這個方法就是這樣,
btnUnzip.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
File file = new File(text.getText());
File file1 = new File(textToSaveUnzipFile.getText());
UnzipUtility.extract(file, file1);
}
}
你是什麼意思是'SWT嚮導'?這是使用JFace'Wizard' /'WizzrdDialog' /'WizardPage'類(它有一個內置的進度監視器),還是隻是簡單的'SWT'? –
在SWT項目中使用wizardDialog – Biswabir
感謝您的回覆,如果我擴展了WizardPage類,那怎麼可能。 – Biswabir