javafx - 重新插入节点 JavaFX 时出现 ConcurrentModificationException
问题描述
我对这段代码有疑问:
for(Node n : start.getChildren()) {
singlewidth = ((CustomController) n).getWidth();
totalwidth += singlewidth;
if(swidth < totalwidth) {
//start.getChildren().remove(b);
start.getChildren().add(mb);
start.getChildren().remove(n);
}
if(swidth > totalwidth){
start.getChildren().add(n);
start.getChildren().remove(mb);
}
}
这里的诀窍是我想遍历 HBox 中的所有元素,并尝试按宽度调整它们。但是在我重新添加节点 n 的地方,NetBeans 抛出了 ConcurrentModificationException。有人可以帮我吗?
解决方案
推荐阅读
- c# - Linq 查询以迭代组并仅过滤选定类型
- c - C中的二进制到十进制。我该如何改进它?
- python - 如何将字符串扩展为数据框中的多行?
- php - Discord Oauth2 PHP 中的 JPEG 头像
- typescript - Visual Studio Code:使用扩展以编程方式查找和替换特定文本
- android - 转换为 int 出错了。安卓
- python - (Python 3 ATM程序)每次提款和存款时如何更新余额?
- docusignapi - 提供访问令牌时,Docusign UserInfo 端点返回 401 Unauthorized
- javascript - node.js 可以让 Web 浏览器(客户端)访问我计算机中的任何目录吗?
- c# - 从数据库中检索自动增量数并基于此更新子行