【问题标题】:how to change background color to imageView in javafx如何在javafx中将背景颜色更改为imageView
【发布时间】:2016-01-13 23:36:49
【问题描述】:

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

【问题讨论】:

  • 将图像视图放入StackPane 并在StackPane 上使用-fx-background-color
  • -fx-background-color,是Region. 的属性。所以,image view 没有这个属性。
  • 谢谢!效果很好

标签: javafx javafx-2 javafx-8 scenebuilder


【解决方案1】:

使用这个

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

按功能应该可以工作。

【讨论】:

  • 这只是在我的 ImageView 上绘制颜色,现在我看不到图像。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-03
  • 2015-11-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多