简体   繁体   English

将鼠标悬停在JavaFX中的CSS上时如何进行圆圈更改填充

[英]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.

相关问题 如何使JavaFX MediaView拉伸媒体填充父级? - How do I make JavaFX MediaView stretch media to fill parent? 如何使JavaFX MediaView拉伸和收缩媒体以填充/适合父容器? - How do I make JavaFX MediaView stretch and shrink media to fill/fit parent container? (JavaFX FXML) 在尝试制作自定义按钮时,如何让图像完全填充按钮? - (JavaFX FXML) While trying to make a custom button, how do I get an image to completely fill a button? 如何使JavaFX MediaView拉伸媒体填充父容器? - How do I make JavaFX MediaView stretch media to fill parent container? 如何在JavaFX中的矩形或圆形内添加图像? - How do I add an image inside a rectangle or a circle in JavaFX? 如何在JavaFX中将一个图像制作成另一个图像,然后在ActionTimer中再次更改它? - How can I make one Image over another in JavaFX and change it again in an ActionTimer? 如何使用CSS设置JavaFX Circle Radius? - How to set JavaFX Circle Radius using CSS? Android:当我在其上拖动其他图像时,如何对图像进行分类并进行图像更改? - Android: How do I make a gird of images views and have the image change when I drag another image over it? JavaFX:用圆弧填充一定百分比的圆 - JavaFX: Fill a percentage of a circle with arc 如何使用CSS在Javafx中更改滑块轨道的颜色? - How do i change the color of a slider track track in Javafx using css?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM