Button 界面按钮和其他功能无法正常工作

Button 界面按钮和其他功能无法正常工作,button,interface,javafx-8,Button,Interface,Javafx 8,我正在使用javaFX scene builder,我制作了一个界面并在其上放置了按钮,但是当我按下一个按钮时,它有一个打印Hello的方法,例如,在我第一次按下它后,它什么也不做,在第二次按下它后,它执行方法2次,它打印Hello 2次,在这之后,它工作得很好,但这种情况发生在我的界面上,我必须按下所有按钮2次,我必须将某个东西悬停2次才能工作,我不知道为什么,有人能帮我吗 这是我的FXML <?xml version="1.0" encoding="UTF

我正在使用javaFX scene builder,我制作了一个界面并在其上放置了按钮,但是当我按下一个按钮时,它有一个打印Hello的方法,例如,在我第一次按下它后,它什么也不做,在第二次按下它后,它执行方法2次,它打印Hello 2次,在这之后,它工作得很好,但这种情况发生在我的界面上,我必须按下所有按钮2次,我必须将某个东西悬停2次才能工作,我不知道为什么,有人能帮我吗

这是我的FXML

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.shape.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane fx:id="aPane" centerShape="false" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0" scaleShape="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controller.MyController">
   <effect>
      <Blend />
   </effect>
   <children>
      <Pane fx:id="secPane" prefHeight="800.0" prefWidth="1280.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
         <children>
            <ComboBox fx:id="ora" layoutX="14.0" layoutY="217.0" prefHeight="25.0" prefWidth="174.0" promptText="Selectati ora" visible="false" />
            <DatePicker fx:id="data" layoutX="14.0" layoutY="127.0" promptText="Selectati data" />
            <Pane fx:id="imgPane" layoutX="200.0" layoutY="14.0" prefHeight="692.0" prefWidth="1066.0" style="-fx-background-color: black;">
               <children>
                  <ImageView fx:id="sMap" fitHeight="692.0" fitWidth="1066.0" layoutX="-1.0" pickOnBounds="true" preserveRatio="true" />
                  <ImageView fx:id="Sirius" fitHeight="11.0" fitWidth="10.0" layoutX="484.0" layoutY="434.0" onMouseEntered="#mouseEnteredSirius" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/sirius.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Procyon" fitHeight="8.0" fitWidth="7.0" layoutX="433.0" layoutY="320.0" onMouseEntered="#mouseEnteredProcyon" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/procyon.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Beetlegeuse" fitHeight="9.0" fitWidth="9.0" layoutX="551.0" layoutY="320.0" onMouseEntered="#mouseEnteredBeetlegeuse" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/beetlegeuse.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Rigel" fitHeight="8.0" fitWidth="9.0" layoutX="599.0" layoutY="399.0" onMouseEntered="#mouseEnteredRigel" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/rigel.png" />
                     </image></ImageView>
                  <ImageView fx:id="Capella" fitHeight="12.0" fitWidth="11.0" layoutX="598.0" layoutY="127.0" onMouseEntered="#mouseEnteredCapella" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/capella.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Aldebaran" fitHeight="6.0" fitWidth="7.0" layoutX="646.0" layoutY="282.0" onMouseEntered="#mouseEnteredAldebaran" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/aldebaran.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Polux" fitHeight="6.0" fitWidth="7.0" layoutX="446.0" layoutY="214.0" onMouseEntered="#mouseEnteredPolux" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/polux.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Castor" fitHeight="4.0" fitWidth="3.0" layoutX="463.0" layoutY="200.0" onMouseEntered="#mouseEnteredCastor" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/castor.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Regulus" fitHeight="4.0" fitWidth="4.0" layoutX="163.0" layoutY="230.0" onMouseEntered="#mouseEnteredRegulus" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/regulus.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Mirphak" fitHeight="5.0" fitWidth="5.0" layoutX="728.0" layoutY="55.0" onMouseEntered="#mouseEnteredMirphak" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/mirphak.png" />
                     </image>
                  </ImageView>
                  <Label layoutX="511.0" layoutY="6.0" prefHeight="35.0" prefWidth="35.0" text=" N" textAlignment="JUSTIFY" textFill="#fc0f0f">
                     <font>
                        <Font name="System Bold" size="22.0" />
                     </font>
                  </Label>
                  <Label layoutX="508.0" layoutY="643.0" prefHeight="35.0" prefWidth="35.0" text="  S" textFill="#fc0f0f">
                     <font>
                        <Font name="System Bold" size="22.0" />
                     </font>
                  </Label>
                  <Label layoutX="14.0" layoutY="338.0" prefHeight="35.0" prefWidth="35.0" text=" W" textFill="#fc0f0f">
                     <font>
                        <Font name="System Bold" size="22.0" />
                     </font>
                  </Label>
                  <Label layoutX="1017.0" layoutY="329.0" prefHeight="35.0" prefWidth="35.0" text="  E" textFill="#fc0f0f">
                     <font>
                        <Font name="System Bold" size="22.0" />
                     </font>
                  </Label>
                  <ImageView fx:id="debug" fitHeight="5.0" fitWidth="5.0" layoutX="487.0" layoutY="438.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/red.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos1" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="1027.0" layoutY="653.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos2" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="964.0" layoutY="658.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos3" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="1010.0" layoutY="636.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos4" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="794.0" layoutY="494.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos5" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="233.0" layoutY="419.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos6" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="84.0" layoutY="434.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos7" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="84.0" layoutY="434.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="infoSirius" fitHeight="100.0" fitWidth="100.0" layoutX="14.0" layoutY="578.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/blueStar.gif" />
                     </image>
                  </ImageView>
                  <Label fx:id="sName1" contentDisplay="CENTER" layoutX="14.0" layoutY="541.0" lineSpacing="5.0" prefHeight="25.0" prefWidth="100.0" text="Sirius" textAlignment="JUSTIFY" textFill="#0d09e1" underline="true" visible="false">
                     <font>
                        <Font name="System Bold" size="20.0" />
                     </font>
                  </Label>
                  <ImageView fx:id="infoBetlegeuse" fitHeight="100.0" fitWidth="100.0" layoutX="113.0" layoutY="578.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/redStar.gif" />
                     </image>
                  </ImageView>
                  <Label fx:id="sName2" layoutX="115.0" layoutY="541.0" prefHeight="30.0" prefWidth="100.0" text="Betlegeuse" textFill="#c90805" underline="true" visible="false">
                     <font>
                        <Font name="System Bold" size="19.0" />
                     </font>
                  </Label>
               </children></Pane>
            <Button fx:id="bInfo" layoutX="14.0" layoutY="401.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="174.0" text="Informatii" />
            <Button fx:id="bHelp" layoutX="14.0" layoutY="470.0" mnemonicParsing="false" prefHeight="42.0" prefWidth="59.0" text="Help" />
            <ImageView fx:id="logo" fitHeight="79.0" fitWidth="174.0" layoutX="14.0" layoutY="5.0" pickOnBounds="true" preserveRatio="true">
               <image>
                  <Image url="@../../Img/SM.jpg" />
               </image></ImageView>
            <Button fx:id="bBack" layoutX="291.0" layoutY="717.0" mnemonicParsing="false" onMouseClicked="#setDateBack" prefHeight="42.0" prefWidth="79.0" text="Inapoi" />
            <Button fx:id="bFwd" layoutX="1075.0" layoutY="716.0" mnemonicParsing="false" onMousePressed="#setDateFwd" prefHeight="42.0" prefWidth="79.0" text="Inainte" />
            <Label fx:id="titluData" layoutX="50.0" layoutY="90.0" prefHeight="25.0" prefWidth="86.0" text="Data">
               <font>
                  <Font name="System Bold" size="18.0" />
               </font>
            </Label>
            <Label fx:id="titluOra" layoutX="50.0" layoutY="179.0" prefHeight="25.0" prefWidth="86.0" text="Ora" visible="false">
               <font>
                  <Font name="System Bold" size="18.0" />
               </font>
            </Label>
            <Label fx:id="sDate" layoutX="710.0" layoutY="716.0" prefHeight="35.0" prefWidth="184.0" text="Data">
               <font>
                  <Font name="System Bold" size="15.0" />
               </font></Label>
            <Label fx:id="pData" layoutX="572.0" layoutY="720.0" prefHeight="27.0" prefWidth="138.0" text="Data selectata :">
               <font>
                  <Font name="System Bold" size="15.0" />
               </font>
            </Label>
            <Label fx:id="pOra" layoutX="572.0" layoutY="741.0" prefHeight="35.0" prefWidth="138.0" text="Ora selectata :">
               <font>
                  <Font name="System Bold" size="15.0" />
               </font>
            </Label>
            <Label fx:id="labelOra" layoutX="710.0" layoutY="746.0" prefHeight="27.0" prefWidth="138.0" text="Ora">
               <font>
                  <Font name="System Bold" size="15.0" />
               </font>
            </Label>
            <Button fx:id="bAf" layoutX="14.0" layoutY="270.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="174.0" text="Afis" />
         </children>
      </Pane>
   </children>
</AnchorPane>
我的申请课

package application;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        try {
            Parent root = FXMLLoader.load(getClass().getResource(
                    "/application/MyView.fxml"));
            Scene scene = new Scene(root);
            scene.getStylesheets().add(
                    getClass().getResource("application.css").toExternalForm());
            primaryStage.setScene(scene);
            primaryStage.show();
            setUserAgentStylesheet(STYLESHEET_CASPIAN);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

在我按下bFwd后,一个蓝点移动了2倍的距离,如输出中所示,它的原始x坐标是484起始x坐标,它从一次点击到519.5,然后到555.0,第二次点击后应该到555.0,然后正常移动35.5个单位点击x坐标对不起,我不能发布图像,我有5个重复,需要10声誉。

您描述的问题是由您的处理方法引起的。FXMLLoader的工作方式是在调用指定方法的控件上注册处理程序

所以


需要注意的是,代码中还有许多其他错误大多数FXML定义的控件没有注释,有些控件是,您在按钮上使用鼠标侦听器而不是处理动作事件:可能还有其他一些。我刚才提到了你所问的那个问题。最好是创建一个隔离点,以便隔离每个错误。另外,请发布可执行示例。没有人可以运行您的代码,因为您引用了所有这些图像,而这些图像与问题无关。

问题是,我将该方法放在了鼠标单击字段中的场景生成器按钮中,因此我需要bFwd.setOnMousePressede->{它几乎可以工作,我不必按两次鼠标按钮,但当我按按钮时它会调用该方法两次。有什么想法吗?无法放入图像,因为我没有足够的代表,但我用坐标解释了。你仍然在处理程序中注册处理程序。不要。我用switch语句修补它,但如果你能找到更好的方法,请告诉我,先生,你将是我的英雄。
        FadeTransition fadeOut = new FadeTransition(Duration.millis(1500));

        fadeOut.setNode(node);

        fadeOut.setFromValue(1.0);
        fadeOut.setToValue(0.0);

        fadeOut.play();
        if (node.getOpacity() == 0.0) {
            node.setVisible(false);
        }

    }
    public void infoFadeOutBetlegeuseLbl(Node node) {

        FadeTransition fadeOut = new FadeTransition(Duration.millis(1500));

        fadeOut.setNode(node);

        fadeOut.setFromValue(1.0);
        fadeOut.setToValue(0.0);

        fadeOut.play();
        if (node.getOpacity() == 0.0) {
            node.setVisible(false);
        }
    }

    public void sky(Node node, double xDest, double yDest) {

        TranslateTransition tTrans = new TranslateTransition(
                Duration.millis(4000), node);

        tTrans.setFromX(0);

        tTrans.setToX(xDest);

        tTrans.setFromY(0);

        tTrans.setToY(yDest);
       

        node.setLayoutX(node.getLayoutX() + xDest);
        node.setLayoutY(node.getLayoutY() + yDest);
        tTrans.setRate(2);
        tTrans.setInterpolator(Interpolator.LINEAR);

       
        tTrans.play();

    }

    public void moveNode(Node node) {

    }

    public void rewindSky(Node node, double xDest, double yDest) {

        TranslateTransition tTrans = new TranslateTransition(
                Duration.seconds(4), node);

        tTrans.setFromX(0);
        tTrans.setToX(xDest);
        tTrans.setRate(2);
        tTrans.setInterpolator(Interpolator.LINEAR);

        tTrans.setFromY(0);
        tTrans.setToY(yDest);
        tTrans.setRate(2);
        tTrans.setInterpolator(Interpolator.LINEAR);

        node.setLayoutX(node.getLayoutX() + xDest);
        node.setLayoutY(node.getLayoutY() + yDest);
        tTrans.play();
    }

    public void followNode(Node node, double xDest, double yDest) {

        if (!nodePos1.isVisible()) {

            tTrans.stop();
        }

        TranslateTransition tTrans = new TranslateTransition(
                Duration.seconds(5), node);

        tTrans.getByX();
        tTrans.setToX(xDest);
        tTrans.setRate(2);
        tTrans.setInterpolator(Interpolator.LINEAR);

        tTrans.getByY();
        tTrans.setToY(yDest);
        tTrans.setRate(2);
        tTrans.setInterpolator(Interpolator.LINEAR);

        node.getLayoutX();
        node.getLayoutY();

        tTrans.play();

    }

    public void splitStar(Node node) {

        if (!nodePos1.isVisible()) {

            nodePos1.setVisible(true);
            nodePos2.setVisible(true);
            nodePos3.setVisible(true);
            nodePos4.setVisible(true);
            nodePos5.setVisible(true);
            nodePos6.setVisible(true);
            nodePos7.setVisible(true);

            nodePos1.setLayoutX(node.getLayoutX());
            nodePos1.setLayoutY(node.getLayoutY());

            nodePos2.setLayoutX(node.getLayoutX());
            nodePos2.setLayoutY(node.getLayoutY());

            nodePos3.setLayoutX(node.getLayoutX());
            nodePos3.setLayoutY(node.getLayoutY());

            nodePos4.setLayoutX(node.getLayoutX());
            nodePos4.setLayoutY(node.getLayoutY());

            nodePos5.setLayoutX(node.getLayoutX());
            nodePos5.setLayoutY(node.getLayoutY());

            nodePos6.setLayoutX(node.getLayoutX());
            nodePos6.setLayoutY(node.getLayoutY());

            nodePos7.setLayoutX(node.getLayoutX());
            nodePos7.setLayoutY(node.getLayoutY());

            followNode(nodePos1, 35.5, 4.5);
            followNode(nodePos2, 35.5 * 2, 4.5 * 2);
            followNode(nodePos6, 35.5 * 3, 4.5 * 3);
            followNode(nodePos5, 0, 0);
            followNode(nodePos3, -35.5, -4.5);
            followNode(nodePos4, -35.5 * 2, -4.5 * 2);
            followNode(nodePos7, 35.5 * 4, 4.5 * 4);

        }

    }

    public void splitStarFalse(Node node) {

        nodePos1.setVisible(false);
        nodePos2.setVisible(false);
        nodePos3.setVisible(false);
        nodePos4.setVisible(false);
        nodePos5.setVisible(false);
        nodePos6.setVisible(false);
        nodePos7.setVisible(false);

        nodePos1.setTranslateX(0);
        nodePos2.setTranslateX(0);
        nodePos3.setTranslateX(0);
        nodePos4.setTranslateX(0);
        nodePos5.setTranslateX(0);
        nodePos6.setTranslateX(0);
        nodePos7.setTranslateX(0);

        nodePos1.setTranslateY(0);
        nodePos2.setTranslateY(0);
        nodePos3.setTranslateY(0);
        nodePos4.setTranslateY(0);
        nodePos5.setTranslateY(0);
        nodePos6.setTranslateY(0);
        nodePos7.setTranslateY(0);

    }

    public void setDateFwd(MouseEvent event) {

        

        bFwd.setOnMousePressed(e -> {

            if (data.getValue() == null) {
                System.out.println("Introduceti data!!!");
            }
            double x = 35.5;
            double y = 4.5;

            if (data.getValue().equals(LocalDate.of(2014, 8, 15))
                    && labelOra.getText().equals("23:00") == true) {

                ld = data.getValue();

                System.out.println("" + ld);
                sDate.setText(ld.toString());

                System.out.println("" + listaOra.get(1).toString());
                labelOra.setText(listaOra.get(1).toString());

                sky(Sirius, x, y);
                sky(Procyon, 35.5, 4.5);
                sky(Beetlegeuse, 35.5, 4.5);
                sky(Polux, 35.5, 4.5);
                sky(Capella, 35.5, 4.5);
                sky(Regulus, 35.5, 4.5);
                sky(Rigel, 35.5, 4.5);
                sky(Aldebaran, 35.5, 4.5);
                sky(Castor, 35.5, 4.5);
                sky(Mirphak, 35.5, 4.5);

                System.out.println("" + Sirius.getLayoutX());
                Sirius.getLayoutY();
            }

            if (data.getValue().equals(LocalDate.of(2014, 8, 15))
                    && labelOra.getText().equals("23:30") == true) {

                sky(Sirius, x, y);
                sky(Procyon, 35.5, 4.5);
                sky(Beetlegeuse, 35.5, 4.5);
                sky(Polux, 35.5, 4.5);
                sky(Capella, 35.5, 4.5);
                sky(Regulus, 35.5, 4.5);
                sky(Rigel, 35.5, 4.5);
                sky(Aldebaran, 35.5, 4.5);
                sky(Castor, 35.5, 4.5);
                sky(Mirphak, 35.5, 4.5);

                System.out.println("succes");

                System.out.println("" + Sirius.getLayoutX());
                System.out.println("" + Sirius.getLayoutY());

            }

         

        });

    }

    public void setDateBack(MouseEvent event) {

        bBack.setOnMouseClicked(e -> {

            if (data.getValue() == null) {
                System.out.println("Introduceti data!!!");
            }

            if (data.getValue().equals(LocalDate.of(2014, 8, 15))) {

                ld = data.getValue();

                System.out.println("" + ld);
                sDate.setText(ld.toString());

                System.out.println("" + ora.getValue());
                labelOra.setText(listaOra.get(0).toString());

                rewindSky(Sirius, -35.5, -4.5);
                rewindSky(Procyon, -35.5, -4.5);
                rewindSky(Beetlegeuse, -35.5, -4.5);
                rewindSky(Polux, -35.5, -4.5);
                rewindSky(Capella, -35.5, -4.5);
                rewindSky(Regulus, -35.5, -4.5);
                rewindSky(Rigel, -35.5, -4.5);
                rewindSky(Aldebaran, -35.5, -4.5);
                rewindSky(Castor, -35.5, -4.5);
                rewindSky(Mirphak, -35.5, -4.5);

                System.out.println("" + Sirius.getLayoutX());
                System.out.println("" + Sirius.getLayoutY());
            }
        });
    }



    public void mouseEnteredSirius(MouseEvent event) {

        Sirius.setOnMouseEntered(e -> {

            new ZoomIn(Sirius, Sirius.getScaleX() * 4, Sirius.getScaleY() * 4);

            infoFadeInSirius(infoSirius);
            infoFadeInSiriusLbl(sName1);

            splitStar(Sirius);

            System.out.println("Mouse draged!!!");
        });

        Sirius.setOnMouseExited(e2 -> {

            new ZoomOut(Sirius);

            infoFadeOutSirius(infoSirius);

            infoFadeOutSiriusLbl(sName1);

            splitStarFalse(Sirius);

            System.out.println("Mouse draged out!!!");
        });

    }

}
package application;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        try {
            Parent root = FXMLLoader.load(getClass().getResource(
                    "/application/MyView.fxml"));
            Scene scene = new Scene(root);
            scene.getStylesheets().add(
                    getClass().getResource("application.css").toExternalForm());
            primaryStage.setScene(scene);
            primaryStage.show();
            setUserAgentStylesheet(STYLESHEET_CASPIAN);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}
<Button fx:id="bBack" ... onMouseClicked="#setDateBack" ... />
public void setDateBack(MouseEvent event) {

    if (data.getValue() == null) {
        System.out.println("Introduceti data!!!");
    }

    if (data.getValue().equals(LocalDate.of(2014, 8, 15))) {

        ld = data.getValue();

        System.out.println("" + ld);
        sDate.setText(ld.toString());

        System.out.println("" + ora.getValue());
        labelOra.setText(listaOra.get(0).toString());

        rewindSky(Sirius, -35.5, -4.5);
        rewindSky(Procyon, -35.5, -4.5);
        rewindSky(Beetlegeuse, -35.5, -4.5);
        rewindSky(Polux, -35.5, -4.5);
        rewindSky(Capella, -35.5, -4.5);
        rewindSky(Regulus, -35.5, -4.5);
        rewindSky(Rigel, -35.5, -4.5);
        rewindSky(Aldebaran, -35.5, -4.5);
        rewindSky(Castor, -35.5, -4.5);
        rewindSky(Mirphak, -35.5, -4.5);

        System.out.println("" + Sirius.getLayoutX());
        System.out.println("" + Sirius.getLayoutY());
    }
}