1、如果此节点已有按钮由此功能,找到他含有IProgressMonitor属性的父类,继承就行,但注意,model属性不要再提供getset方法,否则父类model属性会为空。
2、自己写,通过TPAProgressUtil 获取带风车的幕布组件,而且要另起线程(比如SwingWorker),但一定要记得finally里关掉,
if (monitor != null) {
monitor.done();
monitor = null;
}
private void showMonitor() {
if ((monitor != null) && (!monitor.isDone())) {
return;
}
monitor = getTpaProgressUtil().getTPAProgressMonitor();
monitor.beginTask("", -1);
monitor.setProcessInfo("");
}
public TPAProgressUtil getTpaProgressUtil() {
if (tpaProgressUtil == null) {
tpaProgressUtil = new TPAProgressUtil();
tpaProgressUtil.setContext(getModel().getContext());
}
return tpaProgressUtil;
}
本文介绍如何在UI更新与后台任务间实现同步,包括继承含有IProgressMonitor属性的父类来复用功能,以及使用TPAProgressUtil组件配合SwingWorker线程进行任务监控。文中详细解释了如何正确显示进度幕布并确保资源释放。
1976

被折叠的 条评论
为什么被折叠?



