Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.application.Application;
- import javafx.scene.Scene;
- import javafx.scene.layout.Background;
- import javafx.scene.paint.Color;
- import javafx.scene.control.Button;
- import javafx.scene.control.Label;
- import javafx.scene.control.TextField;
- import javafx.scene.layout.Pane;
- import javafx.stage.Stage;
- import javafx.event.ActionEvent;
- import javafx.event.EventHandler;
- import javax.swing.JOptionPane;
- import javax.swing.JComboBox;
- import javafx.scene.shape.*;
- import javafx.scene.text.*; import javafx.scene.shape.Circle;
- import javafx.util.Duration;
- import javafx.animation.TranslateTransition;
- import javafx.animation.ScaleTransition;
- import javafx.scene.image.Image;
- import javafx.scene.image.ImageView;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import javafx.scene.input.MouseEvent;
- import javafx.scene.Cursor;
- import javafx.scene.effect.DropShadow;
- import javafx.concurrent.Service;
- import javafx.concurrent.Task;
- import java.io.InputStream;
- import javafx.scene.layout.BackgroundImage;
- import javafx.scene.layout.Background;
- import javafx.scene.layout.BackgroundSize;
- import javafx.scene.layout.BackgroundPosition;
- import javafx.scene.layout.BackgroundRepeat;
- import javafx.animation.FadeTransition;
- import javafx.animation.SequentialTransition;
- import javafx.animation.ParallelTransition;
- import java.util.ArrayList;
- import javafx.geometry.Bounds;
- public class sample extends Application{
- Pane pane = new Pane(); int studCount = 0; int guide = 0, ageValue=0;
- Button add, vaccinate, next, none;
- TextField ageField; Text ageWarning, noStudents;
- Text treeText[] = new Text[8]; Circle round[] = new Circle[8]; ImageView tails[] = new ImageView[8];
- Button student[]; ArrayList<Integer> numGuide = new ArrayList<Integer>(); int copy[] = new int[studCount];
- Button studenta, studentb, studentc, studentd, studente, studentf, studentg;
- TranslateTransition toWalk1 = new TranslateTransition(Duration.seconds(4));TranslateTransition toWalk2 = new TranslateTransition(Duration.seconds(4));TranslateTransition toWalk3 = new TranslateTransition(Duration.seconds(4));TranslateTransition toWalk4 = new TranslateTransition(Duration.seconds(3));TranslateTransition toWalk5 = new TranslateTransition(Duration.seconds(3));TranslateTransition toWalk6 = new TranslateTransition(Duration.seconds(2));TranslateTransition toWalk7 = new TranslateTransition(Duration.seconds(2));
- TranslateTransition roomOut = new TranslateTransition(Duration.seconds(6));TranslateTransition roomIn = new TranslateTransition(Duration.seconds(3));
- ScaleTransition treePop = new ScaleTransition(Duration.seconds(.5)); ScaleTransition roundPop = new ScaleTransition(Duration.seconds(.5));
- ParallelTransition pt = new ParallelTransition(treePop, roundPop);
- // Service studentExit = new exit();Service flip = new flipBack(); Service afterExit = new sixSec(); Service treeWait = new threeSec();
- TranslateTransition nextMove = new TranslateTransition(Duration.seconds(1));
- @Override
- public void start(Stage primaryStage) throws FileNotFoundException {
- student = new Button[8];
- add = new Button("ADD");
- vaccinate = new Button("VACCINATE");
- ageField = new TextField();
- ageWarning = new Text("Please Enter Age!");
- noStudents = new Text("There's no student!");
- next = new Button("NEXT");
- none = new Button("NONE");
- addNew();
- studenta = new Button("");
- studentb = new Button("");
- studentc = new Button("");
- studentd = new Button("");
- studente = new Button("");
- studentf = new Button("");
- studentg = new Button("");
- students();
- numGuide.add(9);
- student[1] = studenta;
- student[2] = studentb;
- student[3] = studentc;
- student[4] = studentd;
- student[5] = studente;
- student[6] = studentf;
- student[7] = studentg;
- Scene scene = new Scene(pane, 1000, 600);
- primaryStage.setTitle("asdf");
- primaryStage.setScene(scene);
- primaryStage.show();
- add.setOnAction(new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent event) {
- studCount++;
- toWaitArea();
- System.out.println("studcount " + studCount);
- }});
- next.setOnAction(new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent event) {
- for(int i = 1; i<=studCount; i++){
- Bounds boundsInScene = student[1].localToScene(student[1].getBoundsInLocal());
- nextMove.setToX(boundsInScene.getMaxX()+110);
- nextMove.setNode(student[studCount]);
- nextMove.play();
- //assuming that my subjects are the buttons
- //if i add 7 buttons and i click next, all 7 should walk straight together but the speed of loop is skipping the animation of each
- }
- }});
- }
- public void students(){
- studenta.setLayoutX(-90);
- studenta.setLayoutY(270);
- studenta.setPrefWidth(20);
- studenta.setPrefHeight(100);
- // studenta.setVisible(false);
- studentb.setLayoutX(-90);
- studentb.setLayoutY(270); studentb.setPrefWidth(20);
- studentb.setPrefHeight(100);
- // studentb.setVisible(false);
- studentc.setLayoutX(-90);
- studentc.setLayoutY(270);
- studentc.setPrefWidth(20);
- studentc.setPrefHeight(100);
- // studentc.setVisible(false);
- studentd.setLayoutX(-90);
- studentd.setLayoutY(270);
- studentd.setPrefWidth(20);
- studentd.setPrefHeight(100);
- // studentd.setVisible(false);
- studente.setLayoutX(-90);
- studente.setLayoutY(270);
- studente.setPrefWidth(20);
- studente.setPrefHeight(100);
- // studente.setVisible(false);
- studentf.setLayoutX(-90);
- studentf.setLayoutY(270);
- studentf.setPrefWidth(20);
- studentf.setPrefHeight(100);
- // studentf.setVisible(false);
- studentg.setLayoutX(-90);
- studentg.setLayoutY(270);
- studentg.setPrefWidth(20);
- studentg.setPrefHeight(100);
- // studentg.setVisible(false);
- pane.getChildren().add(studenta);
- pane.getChildren().add(studentb);
- pane.getChildren().add(studentc);
- pane.getChildren().add(studentd);
- pane.getChildren().add(studente);
- pane.getChildren().add(studentf);
- pane.getChildren().add(studentg);
- }
- public void addNew(){
- ageWarning.setLayoutX(180);
- ageWarning.setLayoutY(540);
- ageWarning.setStyle("-fx-text-fill: #ff0a3b; ");
- ageWarning.setVisible(false);
- pane.getChildren().addAll(ageWarning);
- ageField.setPrefWidth(50);
- ageField.setPrefHeight(40);
- ageField.setLayoutX(150);
- ageField.setLayoutY(540);
- ageField.setPromptText("Age");
- ageField.setVisible(false);
- pane.getChildren().addAll(ageField);
- add.setPrefWidth(100);
- add.setPrefHeight(40);
- add.setLayoutX(40);
- add.setLayoutY(540);
- add.setCursor(Cursor.OPEN_HAND);
- pane.getChildren().addAll(add);
- vaccinate.setPrefWidth(100);
- vaccinate.setPrefHeight(40);
- vaccinate.setLayoutX(400);
- vaccinate.setLayoutY(540);
- vaccinate.setCursor(Cursor.OPEN_HAND);
- pane.getChildren().addAll(vaccinate);
- next.setPrefWidth(100);
- next.setPrefHeight(40);
- next.setLayoutX(550);
- next.setLayoutY(540);
- next.setCursor(Cursor.OPEN_HAND);
- pane.getChildren().addAll(next);
- noStudents.setLayoutX(480);
- noStudents.setLayoutY(540);
- noStudents.setStyle("-fx-text-fill: #ff0a3b; ");
- noStudents.setVisible(false);
- pane.getChildren().addAll(noStudents);
- none.setPrefWidth(100);
- none.setPrefHeight(40);
- none.setLayoutX(700);
- none.setLayoutY(540);
- none.setCursor(Cursor.OPEN_HAND);
- pane.getChildren().addAll(none);
- }
- public void toWaitArea(){
- if(studCount==1){
- student[studCount].setVisible(true);
- toWalk1.setToX(700);
- toWalk1.setNode(student[studCount]);
- toWalk1.play();
- }else if(studCount==2){
- student[studCount].setVisible(true);
- toWalk2.setToX(610);
- toWalk2.setNode(student[studCount]);
- toWalk2.play();
- }else if(studCount==3){
- student[studCount].setVisible(true);
- toWalk3.setToX(520);
- toWalk3.setNode(student[studCount]);
- toWalk3.play();
- }else if(studCount==4){
- student[studCount].setVisible(true);
- toWalk4.setToX(430);
- toWalk4.setNode(student[studCount]);
- toWalk4.play();
- }else if(studCount==5){
- student[studCount].setVisible(true);
- toWalk5.setToX(340);
- toWalk5.setNode(student[studCount]);
- toWalk5.play();
- }else if(studCount==6){
- student[studCount].setVisible(true);
- toWalk6.setToX(250);
- toWalk6.setNode(student[studCount]);
- toWalk6.play();
- }else if(studCount==7){
- student[studCount].setVisible(true);
- toWalk7.setToX(160);
- toWalk7.setNode(student[studCount]);
- toWalk7.play();
- }
- }
- public static void main(String[] args) {
- launch(args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement