我有一个包含许多ImageView节点的网格窗格 . 单击ImageView时,我想删除图像 .
ImageView image = new ImageView("https://www.google.co.in/images/nav_logo242.png");
在一次行动中,我做了:
image.setImage(null); System.gc();
但是,我仍然看到旧图像 .
image.getImage(); // it returns null
这应该工作:
image.setImage(null);
发布您的整个代码以检查错误 .
gridPane.getChildren().remove(image);
使用
ImageView.imageProperty().set(null);
这对我来说非常有用
3 回答
这应该工作:
发布您的整个代码以检查错误 .
使用
这对我来说非常有用