首页 文章

如何在javafx中将背景颜色更改为imageView

提问于
浏览
1

我有一个带有透明图像(PNG)的ImageView,因此当鼠标悬停在图像视图上时,图像不会填充图像视图的完整矩形我想要更改图像视图的矩形的背景颜色 . 在Css我怎么做?图像视图节点是否具有属性-fx-background颜色?我试过,这对我不起作用 . 我有一个链接到.FXML的css文件

1 回答

  • 1

    用这个

    Bounds bound = ImageView.getBoundsInLocal(); //getting co-ordinates
    ImageView.setEffect(ColorInput(bound.getMinX(), bound.getMinY(),
                bound.getWidth(), bound.getHeight(), Color.YELLOW));
    

    按功能应该工作 .

相关问题