ProcessBuilder设置了JProgressBar

时间:2017-02-01 09:13:26

标签: java swingworker jprogressbar

我在swingworker中使用processbuilder在cmd中执行总共6个命令。是否可以在每个命令的成功之间更新JProgressBar的值?

这些是流程构建器中包含的数组:

protected String[] cmdBoot = {
    "dism /mount-wim /wimfile:boot.wim /index:2 /mountdir:mount",
    "dism /image:mount /add-driver:\"driver\" /recurse",
    "dism /unmount-wim /mountdir:mount /commit"
};
protected String[] cmdInstall = {
    "",
    "dism /image:mount /add-driver:\"driver\" /recurse",
    "dism /unmount-wim /mountdir:mount /commit"
};

我的processbuilder看起来像这样:

// boot.wim
ProcessBuilder bootBuilder = new ProcessBuilder(
    "cmd.exe", "/c", cmdBoot[0] + " && " + cmdBoot[1] + " && " + cmdBoot[2]
);

// install.wim
ProcessBuilder installBuilder = new ProcessBuilder(
    "cmd.exe", "/c", cmdInstall[0] + " && " + cmdInstall[1] + " && " + cmdInstall[2]
);

我想要做的是在cmdBoot[0]cmdBoot[1]之间设置进度条的值,这可能吗?如果是这样;我怎么能这样做?

0 个答案:

没有答案