Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package application;
- import java.util.Timer;
- import java.util.TimerTask;
- import javafx.application.Application;
- import javafx.scene.Group;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.Label;
- import javafx.scene.layout.Pane;
- import javafx.stage.Stage;
- public class Main extends Application {
- public float clic ;
- public float time = 10000;
- public float result ;
- @Override
- public void start(Stage primaryStage) {
- try {
- Group root = new Group();
- Scene scene = new Scene(root,225,150);
- Label la = new Label(" Clic pour commencer le test !");
- root.setAutoSizeChildren(true);
- Button bu = new Button("Clic");
- bu.setLayoutX(91);
- bu.setLayoutY(50);
- bu.setOnAction(event ->{
- clic = clic + 1;
- Label lab = new Label("Clic : " + clic);
- lab.setLayoutX(86);
- lab.setLayoutY(30);
- try {
- Thread.sleep(20);
- root.getChildren().add(lab);
- Thread.sleep(20);
- root.getChildren().remove(lab);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- System.out.println(clic);
- Timer timer = new Timer();
- timer.schedule(new TimerTask() {
- @Override
- public void run() {
- result = clic / 10 ;
- System.out.println("Ton CPS est de : " + result + ".");
- Label res = new Label(" Ton \"" + "CPS" + "\" est de : " + result );
- res.setLayoutY(100);
- root.getChildren().addAll(res);
- }
- }, 10000);
- });
- Button removeButton = new Button("Recomencer le test !");
- removeButton.setLayoutY(135);
- removeButton.setOnAction(event -> {
- System.out.println("---{ }---");
- System.out.println( clic + "| |" +result + "\n");
- clic = 0; result = 0;
- System.out.println(clic + "| |" +result);
- });
- Pane pane = new Pane();
- pane.getStyleClass().add("bg-black-style");
- root.getChildren().addAll(bu, la, removeButton, pane);
- primaryStage.setResizable(false);
- primaryStage.setTitle("TestCPS");
- primaryStage.setScene(scene);
- primaryStage.show();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- public static void main(String[] args) {
- launch(args);
- System.out.println("L'aplication vient de s'éiteindre !");
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement