首页 文章

javafx图像从imageview中删除

提问于
浏览
2

我有一个包含许多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

3 回答

  • 0

    这应该工作:

    image.setImage(null);
    

    发布您的整个代码以检查错误 .

  • 4
    gridPane.getChildren().remove(image);
    
  • -1

    使用

    ImageView.imageProperty().set(null);
    

    这对我来说非常有用

相关问题