Java 程序运行正常,但显示了太多错误

Java 程序运行正常,但显示了太多错误,java,exception,javafx,Java,Exception,Javafx,当我的程序运行时,它会显示这些错误,即使它也按照我的要求运行。这些错误只有在按下easy或hard键并获得至少两个点时才会弹出。我的代码将在错误下面给出 Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Children: duplicate children added: parent = Pane@3175f25b[styleClass=root] at javafx

当我的程序运行时,它会显示这些错误,即使它也按照我的要求运行。这些错误只有在按下easy或hard键并获得至少两个点时才会弹出。我的代码将在错误下面给出

Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Children: duplicate children added: parent = Pane@3175f25b[styleClass=root]
    at javafx.scene.Parent$2.onProposedChange(Parent.java:454)
    at com.sun.javafx.collections.VetoableListDecorator.add(VetoableListDecorator.java:206)
    at TransFo.TransoFo.lambda$null$2(TransoFo.java:251)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Node.fireEvent(Node.java:8411)
    at javafx.scene.control.Button.fire(Button.java:185)
    at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:380)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:294)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:416)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:415)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    at com.sun.glass.ui.View.notifyMouse(View.java:937)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)
这是我的密码

public class TransoFo extends Application{

    private int total;

        public void start(Stage stage){
                Pane p = new Pane();
        Button b = new Button("easy");
        b.setStyle("-fx-background-radius: 3em;" + 
                "-fx-background-color: #66a3ff;" +
                "-fx-min-width: 120;" +
                "-fx-min-height: 40;" +
                "-fx-max-width: 120;" +
                "-fx-min-height: 40;" +
                "-fx-cursor: hand;" +
                "-fx-font-size: 15;" +
                "-fx-text-fill: white;"); 
        b.setLayoutX(307);
        b.setLayoutY(400);

        Button hard = new Button("hard");
        hard.setStyle("-fx-background-radius: 3em;" + 
                "-fx-background-color: #66a3ff;" +
                "-fx-min-width: 120;" +
                "-fx-min-height: 40;" +
                "-fx-max-width: 120;" +
                "-fx-font-size: 15;" +
                "-fx-min-height: 40;" +
                "-fx-cursor: hand;" + 
                "-fx-text-fill: white;");
        hard.setLayoutX(307);
        hard.setLayoutY(450);



             Circle bi = new Circle();
            Rectangle biRec = new Rectangle();
            Circle circle = new Circle();
            Rectangle rec = new Rectangle();

            rec.setWidth(20);
            rec.setHeight(30);

            rec.setArcWidth(5);
            rec.setArcHeight(5);
            rec.setStyle("-fx-fill: #ff9933;" +
                    "-fix-stroke-width: 20;" +
                    "-fix-stroke: #ff4d4d;");


            circle.setStyle("-fx-fill: #88ff4d;" +
                    "-fx-stroke-width: 12;" +
                    "-fx-stroke: #3399ff;");
            circle.setCenterX(370);
            circle.setCenterY(250);
            circle.setRadius(50);

            biRec.setWidth(30);
            biRec.setHeight(20);
            biRec.setArcWidth(5);
            biRec.setArcHeight(5);
            biRec.setStyle("-fx-fill: #ff9933;" +
                    "-fix-stroke-width: 20;" +
                    "-fix-stroke: #ff4d4d;");

            bi.setStyle("-fx-fill: #88ff4d;" +
                    "-fx-stroke-width: 12;" +
                    "-fx-stroke: #3399ff;");
            bi.setCenterX(370);
            bi.setCenterY(250);
            bi.setRadius(100);
            p.getChildren().addAll(bi, biRec, circle, rec);
            // transition for small circle and rectangle
            PathTransition pt1 = new PathTransition();
            pt1.setDuration(Duration.millis(1200));
            pt1.setPath(bi);
            pt1.setNode(biRec);
            pt1.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
            pt1.setCycleCount(Timeline.INDEFINITE);
            pt1.setAutoReverse(false);

           pt1.play();

             PathTransition pt3 = new PathTransition();
            pt3.setDuration(Duration.millis(800));
            pt3.setPath(circle);
            pt3.setNode(rec);
            pt3.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
            pt3.setCycleCount(Timeline.INDEFINITE);
            pt3.setAutoReverse(false);

           pt3.play();

//            button play event lambda expression                              
        b.setOnAction((ActionEvent event) -> {
            bi.setVisible(false);
            biRec.setVisible(false);
            circle.setVisible(false);
            rec.setVisible(false);
                 b.setVisible(false); 

            Circle big = new Circle();
            // create rectangle for big circle
            Rectangle bigRec = new Rectangle();
            Circle circ = new Circle();
            Rectangle r = new Rectangle();
            //event for small rectangle
            r.setWidth(20);
            r.setHeight(30);


            r.setArcWidth(5);
            r.setArcHeight(5);
            r.setStyle("-fx-fill: #ff9933;" +
                    "-fix-stroke-width: 20;" +
                    "-fix-stroke: #ff4d4d;");

            circ.setStyle("-fx-fill: #88ff4d;" +
                    "-fx-stroke-width: 12;" +
                    "-fx-stroke: #3399ff;");
            circ.setCenterX(370);
            circ.setCenterY(300);
            circ.setRadius(50);


            bigRec.setWidth(30);
            bigRec.setHeight(20);
            bigRec.setArcWidth(5);
            bigRec.setArcHeight(5);
            bigRec.setStyle("-fx-fill: #ff9933;" +
                    "-fix-stroke-width: 20;" +
                    "-fix-stroke: #ff4d4d;");

            big.setStyle("-fx-fill: #88ff4d;" +
                    "-fx-stroke-width: 12;" +
                    "-fx-stroke: #3399ff;");
            big.setCenterX(370);
            big.setCenterY(300);
            big.setRadius(100);

            // transition for small circle and rectangle
            PathTransition pt2 = new PathTransition();
            pt2.setDuration(Duration.millis(1200));
            pt2.setPath(big);
            pt2.setNode(bigRec);
            pt2.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
            pt2.setCycleCount(Timeline.INDEFINITE);
            pt2.setAutoReverse(true);

            pt2.play();

            PathTransition pt = new PathTransition();
            pt.setDuration(Duration.millis(800));
            pt.setPath(circ);
            pt.setNode(r);
            pt.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
            pt.setCycleCount(Timeline.INDEFINITE);
            pt.setAutoReverse(false);

            pt.play();     


            Button b2 = new Button(" | | ");
              b2.setStyle("-fx-background-radius: 3em;" + 
                "-fx-background-color: #66a3ff;" +
                "-fx-min-width: 70;" +
                "-fx-min-height: 40;" +
                "-fx-max-width: 700;" +
                "-fx-min-height: 40;" +
                "-fx-cursor: hand;" + 
                "-fx-text-fill: white;");
        b2.setLayoutX(670);
        b2.setLayoutY(10);

        b2.setOnAction((ActionEvent event1) -> {
            pt2.stop();
            pt.stop();
            });                

       Button b3  = new Button(" ▶ ");
        b3.setStyle("-fx-background-radius: 3em;" + 
                "-fx-background-color: #66a3ff;" +
                "-fx-min-width: 70;" +
                "-fx-min-height: 40;" +
                "-fx-max-width: 700;" +
                "-fx-min-height: 40;" +
                "-fx-cursor: hand;" + 
                   "-fx-text-fill: white;");
                   b3.setLayoutX(590);
                   b3.setLayoutY(10);

                   b3.setOnAction((ActionEvent event2) -> {
                                pt.play();
                                pt2.play();

                            });     
                Button match = new Button(" Match ");
                match.setStyle("-fx-background-radius: 3em;" + 
                "-fx-background-color: #66a3ff;" +
                "-fx-min-width: 120;" +
                "-fx-min-height: 40;" +
                "-fx-max-width: 120;" +
                "-fx-min-height: 40;" +
                "-fx-cursor: hand;" + 
                "-fx-text-fill: white;");
                match.setLayoutX(310);
                match.setLayoutY(450);         

                Label scoreTitle = new Label("Score");  

                scoreTitle.setFont(new Font("Courier New bold", 30));
                scoreTitle.setLayoutX(310);
                scoreTitle.setLayoutY(40);
              // here is the button Match's event (lambda expression)
               Label score = new Label("0");


                 match.setOnAction((ActionEvent evt) -> {

                     Bounds bBounds = bigRec.getBoundsInParent();
                     Bounds bounds = r.getBoundsInParent();

                     if (bounds.getMinY() <= bBounds.getMaxY() && bounds.getMaxY() >= bBounds.getMinY()) {
                      total += 1;
                       String str = Integer.toString(total);
                         score.setText(str);
                         score.setFont(new Font("Courier New bold", 20));
                          score.setLayoutX(350);
                          score.setLayoutY(90);
                          p.getChildren().add(score);

                            pt.play();
                          pt2.play();

                   }
                     else {
                         total = 0;
                         String str = Integer.toString(total);
                         score.setText(str);
                         score.setFont(new Font("Courier New bold", 20));
                          score.setLayoutX(350);
                          score.setLayoutY(90);
                          p.getChildren().add(score);
                     }
                }); 

            p.getChildren().addAll(big, bigRec, circ, r, b2, b3, match, scoreTitle);
                //fade transition for 
            FadeTransition ft = new FadeTransition(Duration.millis(1500), big);
            ft.setFromValue(0.1);
            ft.setToValue(1);
            ft.play();
               //transition for big rec
            FadeTransition ft2 = new FadeTransition(Duration.millis(1500), bigRec);
            ft2.setFromValue(0.1);
            ft2.setToValue(1);
            ft2.play();
               //transition for  circ
            FadeTransition ft3 = new FadeTransition(Duration.millis(1500), circ);
            ft3.setFromValue(0.1);
            ft3.setToValue(1);
            ft3.play();
               //transition for r
            FadeTransition ft4 = new FadeTransition(Duration.millis(1500), r);
            ft4.setFromValue(0.1);
            ft4.setToValue(1);
            ft4.play();
               //transition for match
            FadeTransition ft5 = new FadeTransition(Duration.millis(1500), match);
            ft5.setFromValue(0.1);
            ft5.setToValue(1);
            ft5.play();
               //transition for pause button
            FadeTransition ft6 = new FadeTransition(Duration.millis(3000), b2);
            ft6.setFromValue(0.1);
            ft6.setToValue(1);
            ft6.play();
               //transtion for play button
            FadeTransition ft7 = new FadeTransition(Duration.millis(3000), b3);
            ft7.setFromValue(0.1);
            ft7.setToValue(1);
            ft7.play();
        });



        hard.setOnAction((ActionEvent evter) -> {
                 bi.setVisible(false);
            biRec.setVisible(false);
            circle.setVisible(false);
            rec.setVisible(false);
                 b.setVisible(false);   

            Circle big = new Circle();
            // create rectangle for big circle
            Rectangle bigRec = new Rectangle();
            Circle circ = new Circle();
            Rectangle r = new Rectangle();
            //event for small rectangle
            r.setWidth(20);
            r.setHeight(30);


            r.setArcWidth(5);
            r.setArcHeight(5);
            r.setStyle("-fx-fill: #ff9933;" +
                    "-fix-stroke-width: 20;" +
                    "-fix-stroke: #ff4d4d;");

            circ.setStyle("-fx-fill: #88ff4d;" +
                    "-fx-stroke-width: 12;" +
                    "-fx-stroke: #3399ff;");
            circ.setCenterX(370);
            circ.setCenterY(300);
            circ.setRadius(50);


            bigRec.setWidth(30);
            bigRec.setHeight(20);
            bigRec.setArcWidth(5);
            bigRec.setArcHeight(5);
            bigRec.setStyle("-fx-fill: #ff9933;" +
                    "-fix-stroke-width: 20;" +
                    "-fix-stroke: #ff4d4d;");

            big.setStyle("-fx-fill: #88ff4d;" +
                    "-fx-stroke-width: 12;" +
                    "-fx-stroke: #3399ff;");
            big.setCenterX(370);
            big.setCenterY(300);
            big.setRadius(100);

            // transition for small circle and rectangle
            PathTransition pt2 = new PathTransition();
            pt2.setDuration(Duration.millis(1100));
            pt2.setPath(big);
            pt2.setNode(bigRec);
            pt2.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
            pt2.setCycleCount(Timeline.INDEFINITE);
            pt2.setAutoReverse(true);

            pt2.play();

            PathTransition pt = new PathTransition();
            pt.setDuration(Duration.millis(700));
            pt.setPath(circ);
            pt.setNode(r);
            pt.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
            pt.setCycleCount(Timeline.INDEFINITE);
            pt.setAutoReverse(false);

            pt.play();     


            Button b2 = new Button(" | | ");
              b2.setStyle("-fx-background-radius: 3em;" + 
                "-fx-background-color: #66a3ff;" +
                "-fx-min-width: 70;" +
                "-fx-min-height: 40;" +
                "-fx-max-width: 700;" +
                "-fx-min-height: 40;" +
                "-fx-cursor: hand;" + 
                "-fx-text-fill: white;");
        b2.setLayoutX(670);
        b2.setLayoutY(10);

        b2.setOnAction((ActionEvent event1) -> {
            pt2.stop();
            pt.stop();
            });                

       Button b3  = new Button(" ▶ ");
        b3.setStyle("-fx-background-radius: 3em;" + 
                "-fx-background-color: #66a3ff;" +
                "-fx-min-width: 70;" +
                "-fx-min-height: 40;" +
                "-fx-max-width: 700;" +
                "-fx-min-height: 40;" +
                "-fx-cursor: hand;" + 
                   "-fx-text-fill: white;");
                   b3.setLayoutX(590);
                   b3.setLayoutY(10);

                   b3.setOnAction((ActionEvent event2) -> {
                                pt.play();
                                pt2.play();

                            });     
                Button match = new Button(" Match ");
                match.setStyle("-fx-background-radius: 3em;" + 
                "-fx-background-color: #66a3ff;" +
                "-fx-min-width: 120;" +
                "-fx-min-height: 40;" +
                "-fx-max-width: 120;" +
                "-fx-min-height: 40;" +
                "-fx-cursor: hand;" + 
                "-fx-text-fill: white;");
                match.setLayoutX(310);
                match.setLayoutY(450);   

                Label scoreTitle = new Label("Score");  

                scoreTitle.setFont(new Font("Courier New bold", 30));
                scoreTitle.setLayoutX(310);
                scoreTitle.setLayoutY(40);

                Label score = new Label("0");
              // here is the button Match's event (lambda expression)
                 match.setOnAction((ActionEvent evt) -> {

                     Bounds bBounds = bigRec.getBoundsInParent();
                     Bounds bounds = r.getBoundsInParent();

                     if (bounds.getMinY() <= bBounds.getMaxY() && bounds.getMaxY() >= bBounds.getMinY()) {
                      total += 1;
                       String str = Integer.toString(total);
                          score.setText(str);
                         score.setFont(new Font("Courier New bold", 20));
                          score.setLayoutX(350);
                          score.setLayoutY(90);
                          p.getChildren().add(score);

                            pt.play();
                          pt2.play();

                   }
                     else{
                         total = 0;
                             String str = Integer.toString(total);
                          score.setText(str);
                         score.setFont(new Font("Courier New bold", 20));
                          score.setLayoutX(350);
                          score.setLayoutY(90);
                          p.getChildren().add(score);
                     }
                });

            p.getChildren().addAll(big, bigRec, circ, r, b2, b3, match, scoreTitle);
                //fade transition for 
            FadeTransition ft = new FadeTransition(Duration.millis(1500), big);
            ft.setFromValue(0.1);
            ft.setToValue(1);
            ft.play();
               //transition for big rec
            FadeTransition ft2 = new FadeTransition(Duration.millis(1500), bigRec);
            ft2.setFromValue(0.1);
            ft2.setToValue(1);
            ft2.play();
               //transition for  circ
            FadeTransition ft3 = new FadeTransition(Duration.millis(1500), circ);
            ft3.setFromValue(0.1);
            ft3.setToValue(1);
            ft3.play();
               //transition for r
            FadeTransition ft4 = new FadeTransition(Duration.millis(1500), r);
            ft4.setFromValue(0.1);
            ft4.setToValue(1);
            ft4.play();
               //transition for match
            FadeTransition ft5 = new FadeTransition(Duration.millis(1500), match);
            ft5.setFromValue(0.1);
            ft5.setToValue(1);
            ft5.play();
               //transition for pause button
            FadeTransition ft6 = new FadeTransition(Duration.millis(3000), b2);
            ft6.setFromValue(0.1);
            ft6.setToValue(1);
            ft6.play();
               //transtion for play button
            FadeTransition ft7 = new FadeTransition(Duration.millis(3000), b3);
            ft7.setFromValue(0.1);
            ft7.setToValue(1);
            ft7.play();
            // transition for Score Label
            FadeTransition ft8 = new FadeTransition(Duration.millis(3000), scoreTitle);
            ft8.setFromValue(0.1);
            ft8.setToValue(1);
            ft8.play();
            // transition for
        });

        p.getChildren().addAll(b, hard);
        p.setStyle("-fx-background-color: #88ff4d;");
        Scene s = new Scene(p, 750, 650);
        stage.setResizable(false);
        stage.setScene(s);
        stage.show();
 }      
    public static void main(String[] args) {
        Application.launch(args);
    } 
}
公共类TransoFo扩展应用程序{
私人整数合计;
公众假期开始(阶段){
窗格p=新窗格();
按钮b=新按钮(“简易”);
b、 设置样式(“-fx背景半径:3em;”+
“-fx背景色:#66a3ff;”+
“-fx最小宽度:120;”+
“-fx最小高度:40;”+
“-fx最大宽度:120;”+
“-fx最小高度:40;”+
“-fx光标:手动;”+
“-fx字体大小:15;”+
“-fx文本填充:白色;”;
b、 setLayoutX(307);
b、 setLayoutY(400);
按钮硬=新按钮(“硬”);
硬设置样式(“-fx背景半径:3em;”+
“-fx背景色:#66a3ff;”+
“-fx最小宽度:120;”+
“-fx最小高度:40;”+
“-fx最大宽度:120;”+
“-fx字体大小:15;”+
“-fx最小高度:40;”+
“-fx光标:手;”+
“-fx文本填充:白色;”;
硬布局(307);
硬的,硬的(450);
圆圈bi=新圆圈();
矩形biRec=新矩形();
圆圈=新圆圈();
矩形rec=新矩形();
记录设定宽度(20);
记录设定高度(30);
记录设定弧宽(5);
记录setArcHeight(5);
记录设置样式(“-fx填充:#ff9933+
“-固定笔划宽度:20;”+
“-固定行程:#ff4d;”;
圆圈。设置样式(“-fx填充:#88ff4d;”+
“-fx笔划宽度:12;”+
“-fx笔划:#3399ff;”;
圆.setCenterX(370);
圆整度(250);
圆。设定半径(50);
设置宽度(30);
设置高度(20);
设置弧宽(5);
biRec.setArcHeight(5);
biRec.setStyle(“-fx填充:#ff9933+
“-固定笔划宽度:20;”+
“-固定行程:#ff4d;”;
bi.setStyle(“-fx填充:#88ff4d;”+
“-fx笔划宽度:12;”+
“-fx笔划:#3399ff;”;
bi.setCenterX(370);
b.setCenterY(250);
设置半径(100);
p、 getChildren().addAll(bi、biRec、circle、rec);
//小圆和矩形的过渡
PathTransition pt1=新的PathTransition();
pt1.设置持续时间(持续时间为毫秒(1200));
pt1.setPath(bi);
pt1.setNode(biRec);
pt1.setOrientation(路径转换、方向类型、正交到切线);
pt1.setCycleCount(时间线不确定);
pt1.设置自动翻转(假);
pt1.play();
PathTransition pt3=新的PathTransition();
pt3.setDuration(Duration.millis(800));
pt3.设置路径(圆形);
pt3.setNode(rec);
pt3.setOrientation(路径转换、方向类型、正交到切线);
pt3.setCycleCount(Timeline.unfinite);
pt3.设置自动翻转(假);
pt3.play();
//按钮播放事件lambda表达式
b、 setOnAction((ActionEvent事件)->{
bi.setVisible(假);
biRec.setVisible(假);
圆形。设置可见(假);
记录设置可见(假);
b、 setVisible(假);
大圆圈=新圆圈();
//为大圆创建矩形
矩形bigRec=新矩形();
圆圈圈=新圆圈();
矩形r=新矩形();
//小矩形的事件
r、 设置宽度(20);
r、 设置高度(30);
r、 设置弧宽(5);
r、 setArcHeight(5);
r、 设置样式(“-fx填充:#ff9933;”+
“-固定笔划宽度:20;”+
“-固定行程:#ff4d;”;
循环设置方式(“-fx填充:#88ff4d+
“-fx笔划宽度:12;”+
“-fx笔划:#3399ff;”;
约setCenterX(370);
赛森特里约(300);
大约设定半径(50);
bigRec.setWidth(30);
bigRec.设置高度(20);
bigRec.设置弧宽(5);
bigRec.setArcHeight(5);
bigRec.setStyle(“-fx填充:#ff9933;”+
“-固定笔划宽度:20;”+
“-固定行程:#ff4d;”;
大。设置样式(“-fx填充:#88ff4d+
“-fx笔划宽度:12;”+
“-fx笔划:#3399ff;”;
大。setCenterX(370);
大。塞森特里(300);
大半径(100);
//小圆和矩形的过渡
PathTransition pt2=新的PathTransition();
pt2.setDuration(Duration.millis(1200));
pt2.设置路径(大);
pt2.setNode(bigRec);
pt2.setOrientation(路径转换、方向类型、正交到切线);
pt2.setCycleCount(Timeline.unfinite);
pt2.设置自动反转(真);
pt2.play();
PathTransition pt=新的PathTransition();
pt.设定持续时间(持续时间毫秒(800));
pt.设置路径(circ);
pt.setNode(r);
pt.setOrientation(路径转换、方向类型、正交到切线);
pt.setCycleCount(时间线不确定);
pt.设置自动翻转(错误);
pt.play();
按钮b2=新按钮(“| |”);
b2.设置样式(“-fx背景半径:3em;”+
“-fx背景色:#66a3ff;”+
p.getChildren().add(score);
Pane p = new Pane();
Label score = new Label("0");
p.getChildren().addAll(bi, biRec, circle, rec, score);
Label score = new Label("0");
match.setOnAction((ActionEvent evt) -> {
    Bounds bBounds = bigRec.getBoundsInParent();
    Bounds bounds = r.getBoundsInParent();
    if (bounds.getMinY() <= bBounds.getMaxY() && bounds.getMaxY() >= bBounds.getMinY()) {
        total += 1;
        String str = Integer.toString(total);
        score.setText(str);
        score.setFont(new Font("Courier New bold", 20));
        score.setLayoutX(350);
        score.setLayoutY(90);
        p.getChildren().add(score);
        pt.play();
        pt2.play();
}....
p.getChildren().add(score);
Label score = new Label("0");
score.setText(str);
score.setFont(new Font("Courier New bold", 20));
score.setLayoutX(350);
score.setLayoutY(90);
p.getChildren().add(score);

match.setOnAction((ActionEvent evt) -> {
    Bounds bBounds = bigRec.getBoundsInParent();
    Bounds bounds = r.getBoundsInParent();
    if (bounds.getMinY() <= bBounds.getMaxY() && bounds.getMaxY() >= bBounds.getMinY()) {
        total += 1;
        String str = Integer.toString(total);
        score.setText(str);
        pt.play();
        pt2.play();
}....