我在答案中使用了自定义的开关按钮。现在,当用户在2值(状态)之间切换时,我想将动画化循环部分。为此,我使用了KeyValue和KeyFrame。
我添加到SwitchButton()方法中的动画片段:
KeyValue start = new KeyValue(button.alignmentProperty(), Pos.CENTER_RIGHT);
KeyValue end = new KeyValue(button.alignmentProperty(), Pos.CENTER_LEFT);
KeyFrame frame = new KeyFrame(Duration.seconds(