0

当我尝试从按钮登录加载窗口时,我有这个异常,没有错误的定义。在它工作正常之前,但现在我不知道为什么它会出现这个错误 java.lang.NullPointerException,控制台中只有这一行,所以我找不到什么问题。听到我的文件。

<SplitPane dividerPositions="0.5" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" orientation="VERTICAL" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controller.MainEntredController">
 <items>
   <MenuBar>
    <menus>
      <Menu mnemonicParsing="false" text="File">
        <items>
          <MenuItem mnemonicParsing="false" text="Close" />
        </items>
      </Menu>
      <Menu mnemonicParsing="false" text="Edit">
        <items>
          <MenuItem mnemonicParsing="false" text="Delete" />
        </items>
      </Menu>
      <Menu mnemonicParsing="false" text="Help">
        <items>
          <MenuItem mnemonicParsing="false" text="About" />
        </items>
      </Menu>
    </menus>
  </MenuBar>
  <TabPane prefHeight="200.0" prefWidth="200.0"  tabClosingPolicy="UNAVAILABLE">
    <tabs>
      <Tab text="Home" />
    </tabs>
  </TabPane>
 </items>
</SplitPane>

对于在名为 MainController 的类中午餐视图的函数

public void loginBtnClick(ActionEvent event) throws Exception{
    String Usern = username.getText();
    String pass = txtpassword.getText();
     try {
         if( con.LoginDatabase(Usern, pass)){
                lblstatus.setText("Login Successfully");
                Stage primaryStage1 = new Stage();

            Parent root = FXMLLoader.load(getClass().getResource("/application/viewsfx/MainEntredHome.fxml"));

                Scene scene = new Scene(root);
                scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
                primaryStage1.setScene(scene);
                primaryStage1.show();

                // closing the login scene
                 Stage stage = (Stage) btnlogin.getScene().getWindow();
                    stage.close();

                }else {
                    lblstatus.setText("Login failed");
                }
    } catch (Exception e) {
        System.out.println(e);
        System.out.println("ani hna mebloki");

    }

关于名为 MainEntreController 的 Splitpane 视图类的控制器,当我单击 logni 时,它向我显示了这个 Eception java.lang.NullPointerException

4

0 回答 0