is there is any way to rotate the Button when i put the mouse on it (hover) ? by using pure JavaFx , or by using CSS Styling ? if not , i look for any simple animation when hover on mouse
有什么方法可以在我把鼠标放在它上面时旋转按钮(悬停)?使用纯JavaFx,还是使用CSS样式?如果没有,我在鼠标悬停时寻找任何简单的动画
1 个解决方案
#1
Just create a RotateTransition
and use mouse handlers to start and pause it:
只需创建一个RotateTransition并使用鼠标处理程序启动和暂停它:
Button button = ... ;
RotateTransition rotation = new RotateTransition(Duration.seconds(0.5), button);
rotation.setCycleCount(Animation.INDEFINITE);
rotation.setByAngle(360);
button.setOnMouseEntered(e -> rotation.play());
button.setOnMouseExited(e -> rotation.pause());
#1
Just create a RotateTransition
and use mouse handlers to start and pause it:
只需创建一个RotateTransition并使用鼠标处理程序启动和暂停它:
Button button = ... ;
RotateTransition rotation = new RotateTransition(Duration.seconds(0.5), button);
rotation.setCycleCount(Animation.INDEFINITE);
rotation.setByAngle(360);
button.setOnMouseEntered(e -> rotation.play());
button.setOnMouseExited(e -> rotation.pause());