FXML Initialize() 抛出 InvocationTargetException

FXML Initialize() throws InvocationTargetException

我试图在 initialize() 方法上设置按钮的文本,但它抛出 InvocationTargetException,如果我尝试获取 FXML 上的任何项目,它是一样的。

FXML:

<VBox fx:id="vbox" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="450.0" spacing="40.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="instaj.LoginController">
   <children>
      <ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true">
         <image>
            <Image url="img/logo.png" />
         </image>
      </ImageView>
      <TextField id="user" maxWidth="200.0" prefHeight="35.0" promptText="Usuario" style="-fx-focus-color: #9a3bab; -fx-faint-focus-color: transparent;" />
      <javafx.scene.control.PasswordField id="pass" maxWidth="200.0" prefHeight="35.0" promptText="Contraseña" style="-fx-focus-color: #9a3bab; -fx-faint-focus-color: transparent;" />
      <Button fx:id="loginBtn" minHeight="30.0" minWidth="150.0" mnemonicParsing="false" onAction="#loginBtnBehavior" style="-fx-background-radius: 30; -fx-background-color: #9a3bab;" text="Iniciar" textFill="WHITE">
         <font>
            <Font size="16.0" />
         </font>
         <cursor>
            <Cursor fx:constant="HAND" />
         </cursor>
      </Button>
      <Label alignment="CENTER" onMouseClicked="#localAccountLinkBehavior" style="-fx-underline: true;" text="Iniciar con perfil abierto de Instagram dentro de Google Chrome." textFill="#0000ee">
         <cursor>
            <Cursor fx:constant="HAND" />
         </cursor>
      </Label>
   </children>
</VBox>

LoginController.java:

public class LoginController implements Initializable {

    @FXML
    Button loginBtn;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        Utils utils = new Utils();
        loginBtn.setText("test");
        //vbox.requestFocus();
        //utils.removeInitialFocus(user, vbox, firstTime);
        throw new UnsupportedOperationException("Not supported yet.");
    }
}

您要求您的程序启动异常:

throw new UnsupportedOperationException("Not supported yet.");

所以它崩溃是正常的:删除它!