javafx image从imageview删除

Ami*_*ngh 2 javafx imageview

我有一个包含许多ImageView节点的网格窗格。单击ImageView时,我想删除图像。

 ImageView image = new ImageView("https://www.google.co.in/images/nav_logo242.png");
Run Code Online (Sandbox Code Playgroud)

在一个动作上,我做到了:

 image.setImage(null);
 System.gc();
Run Code Online (Sandbox Code Playgroud)

但是,我仍然看到较旧的图像。

 image.getImage(); // it returns null
Run Code Online (Sandbox Code Playgroud)

小智 5

这应该工作:

image.setImage(null);
Run Code Online (Sandbox Code Playgroud)

发布整个代码以检查错误。