package experiment8;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.animation.Animation;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.stage.Stage;
import javafx.util.Duration;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.shape.Circle;
import javafx.scene.transform.Rotate;
public class experiment8true extends Application {
int direction = 1;
public void start(Stage primaryStage)
{
Pane pane = new Pane(); //pane(circle arcs)
Circle circle = new Circle(130,120,100);
circle.setFill(null);
circle.setStroke(Color.BLACK);
pane.getChildren().add(circle);
Arc arc[] = new Arc[4]; //arcs
for(int i=0;i<arc.length;i++)
{
arc[i] = new Arc(130,120,90,90,90*i-20,40);
arc[i].setType(ArcType.ROUND);
arc[i].setFill(Color.ORANGE);
pane.getChildren().add(arc[i]);
}
// Timeline animation = new Timeline(new KeyFrame(Duration.millis(20),new EventHandler<ActionEvent>() { //animation
// public void handle(ActionEvent event) {
// Rotate rotate = new Rotate(10*direction,130,120);
// for(int i=0;i<arc.length;i++)
// {
// arc[i].getTransforms().add(rotate);
// }
// }
// }));
EventHandler<ActionEvent> eventHandler=e->{
Rotate rotate = new Rotate(10*direction,130,120);
for(int i=0;i<arc.length;i++)
{
arc[i].getTransforms().add(rotate);
}
};
Timeline animation =new Timeline(new KeyFrame(Duration.millis(20),eventHandler));
animation.setCycleCount(Timeline.INDEFINITE);//永远运动的关键
Button pauseButton = new Button("Pause"); //pause button
pauseButton.setOnAction(e->{
animation.pause();
});
Button resumeButton = new Button("Resume"); //resume button
resumeButton.setOnAction(e->{
animation.play();
});
Button reverseButton = new Button("Reverse") ; //reverse button
reverseButton.setOnAction(e->{
direction=-direction;
});
HBox hbox = new HBox(25); //ox(buttons)
hbox.setPadding(new Insets(200,0,0,20));//设置面板的边框的大小----顶右底左
hbox.getChildren().addAll(pauseButton,resumeButton,reverseButton);
VBox vbox = new VBox(10); //box(pane,hbox)
vbox.setAlignment(Pos.CENTER);
vbox.getChildren().addAll(pane,hbox);
vbox.setStyle("-fx-background-color:null");
Scene scene = new Scene(vbox,260,320); //scene
vbox.layoutXProperty().bind(scene.widthProperty().subtract(260).divide(2));
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

qq_42167596
- 粉丝: 1
最新资源
- 物流手册:国际货运出口流程.doc
- 混凝土质量缺陷处理.doc
- 广东省电子商务员职业资格认证历年真题汇总-理论题附答案(共十一套题-共990小题165页).doc
- EXCEL常见七大图表制作学习课件.ppt
- 第四章总平面布置.docx
- 燃煤锅炉施工组织设计.doc
- 储备梯队人才培养方案.doc
- 山东省地下水资源潜力研究报告提纲.doc
- 第四章:建筑工程工程量清单编制(上).ppt
- Unit3Period5WritingandPresentingideas教案高中英语外研版选择性.docx
- 碗扣钢管楼板模板支架计算书.doc
- 招标文件审批表.docx
- 网络安全与信息实用技术实验1.doc
- SMT主要设备发展情况.doc
- 望京某办公综合楼沃尔玛区域施工合同.doc
- 工程现场临时用电安全隐患检查图文并茂.ppt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


