0

i have this Exception whith no difinition of the error when i am trying to load a window from a button login. before it worked fine, but now i dont know why it shoing this error java.lang.NullPointerException, there is only this line in the console , so i couldnt find whats wrong. hears my files .

<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>

and for the function who lunchs the view in a class Named 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");

    }

and about the controller of the Splitpane view class named MainEntreController, when i click on logni it shows me this Eception java.lang.NullPointerException

2
  • Change your catch block so you see the entire error message. I.e. you need e.printStackTrace();. Then edit your question and post the stack trace (if you are still unable to diagnose it).
    – James_D
    Jan 16, 2016 at 15:57
  • thanks, i found it, i forgot to correct the location of application.css file i forgot to set the correct path , Jan 16, 2016 at 16:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.