Кнопка конструктора сцены javaFX не работает, какое-либо решение? - PullRequest
1 голос
/ 15 февраля 2020

Я пытался решить эту проблему в очень простом приложении, чтобы заставить нажатие кнопки работать, но все, что я пытался (следуя некоторым учебникам или связанным ответам здесь), не работает. Я создал новый проект javaFX, и это файлы, созданные с моими изменениями, PS Я использую netbeans

UserLogin. java

public class UserLogin extends Application {

    @FXML
    Button signup;

    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("FXMLUserSignIn.fxml"));

        Scene scene = new Scene(root);

        stage.setScene(scene);
        stage.show();  
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}

FXMLUserSignInController

    public void SignUpPush(ActionEvent event) throws IOException {
        Parent userSignIn = FXMLLoader.load(getClass().getResource("FXMLUserSignUp.fxml"));
        Scene userSignInSc = new Scene(userSignIn);

        Stage window = (Stage)(((Node)event.getSource()).getScene().getWindow());

        window.setScene(userSignInSc);
        window.show();

    } 

    @Override
    public void initialize(URL location, ResourceBundle resources) {
    }   
}

FXMLUserSignUpController

public class FXMLUserSignUpController implements Initializable {

    public void BackPush(ActionEvent event) throws IOException {
        Parent userSignIn = FXMLLoader.load(getClass().getResource("FXMLUserSignIn.fxml"));
        Scene userSignInSc = new Scene(userSignIn);

        Stage window = (Stage)(((Node)event.getSource()).getScene().getWindow());

        window.setScene(userSignInSc);
        window.show();

    } 
    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }  
}

FXMLUserSignIn

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

<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXPasswordField?>
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.text.Font?>

<AnchorPane id="AnchorPane" prefHeight="301.0" prefWidth="437.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.donation.controllers.FXMLUserSignInController">
   <children>
      <Pane layoutX="19.0" layoutY="14.0" prefHeight="269.0" prefWidth="401.0" style="-fx-background-color: #ffffff;">
         <children>
            <JFXTextField focusColor="#47daf4" labelFloat="true" layoutX="103.0" layoutY="33.0" prefHeight="35.0" prefWidth="204.0" promptText="Email" unFocusColor="#b2afaf">
               <font>
                  <Font size="13.0" />
               </font>
            </JFXTextField>
            <JFXPasswordField focusColor="#47daf4" labelFloat="true" layoutX="103.0" layoutY="119.0" prefHeight="35.0" prefWidth="204.0" promptText="Password" unFocusColor="#b2afaf">
               <font>
                  <Font size="13.0" />
               </font>
            </JFXPasswordField>
            <JFXButton buttonType="RAISED" layoutX="95.0" layoutY="201.0" prefHeight="35.0" prefWidth="68.0" ripplerFill="WHITE" style="-fx-background-color: #2196F3;" text="Login" textFill="WHITE" />
            <JFXButton fx:id="handle" buttonType="RAISED" layoutX="223.0" layoutY="201.0" onAction="#SignUpPush" prefHeight="35.0" prefWidth="68.0" ripplerFill="WHITE" style="-fx-background-color: #2196F3;" text="Sign up" textFill="WHITE" />
         </children>
      </Pane>
   </children>
</AnchorPane>

FXMLUserSignUp

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

<?import com.jfoenix.controls.JFXButton?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>


<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.171" fx:controller="com.donation.controllers.FXMLUserSignUpController">
   <children>
      <Label layoutX="260.0" layoutY="177.0" prefHeight="17.0" prefWidth="102.0" text="hi" />
      <JFXButton layoutX="260.0" layoutY="265.0" onAction="#BackPush" text="Back" />
   </children>
</AnchorPane>

Я был бы очень благодарен за любую помощь.

...