[英]How do i make a circle change fill when hovered over with CSS in JavaFX
I have a circle that is inside an hBox. 我在hBox内有一个圆圈。 Now i want that circle to change its fill to another color when the mouse cursor hovers over it. 现在,当鼠标指针悬停在该圆圈上时,我希望该圆圈将其填充更改为另一种颜色。 Is that possible to do in JavaFX with CSS, if not what is the best way to do it programmatically? 如果没有,用JavaFX在JavaFX中可以做到这一点,如果没有,最好的编程方式是什么? i tried: 我试过了:
#circleID: hover {
-fx-background-color: #fff;
-fx-fill: #fff;
-fx-cell-hover-color: #fff;
}
the circle is a shape so try with fill method : 圆是一个形状,请尝试使用fill方法:
#circleID{
-fx-fill:red;
}
#circleID:hover{
-fx-fill:blue;
}
and in your java code add this : 并在您的Java代码中添加以下代码:
circle.setId("circleID");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.