0

JavaFX newbie here. I am using NetBeans 8.0 IDE and I placed my FXML file RootLayout.fxml in com.techie.java.view package. I am loading this fxml file using the following code declared in com.techie.java.controller package:

private void initRootLayout() {
    try {
        pane = FXMLLoader.load(ContactManager.class.getResource("/view/RootLayout.fxml"));

        Scene scene = new Scene(pane);
        stage.setScene(scene);
        stage.show();
    } catch (IOException ie) {
        ie.printStackTrace();
    }
}

private void showPersonOverview() {
    try {
        AnchorPane anchorPane = FXMLLoader.load(ContactManager.class.getResource("/view/PersonOverview.fxml"));

        pane.setCenter(anchorPane);
    } catch (IOException ie) {
        ie.printStackTrace();
    }
}

While executing I am getting Null pointer exception at BorderPane pane = FXMLLoader.load(ContactManager.class.getResource("/view/RootLayout.fxml"));.

What am I doing wrong?

2
  • 1
    what line is the error occurring at? Commented Jun 6, 2015 at 15:47
  • What does getResource() return? Commented Jun 6, 2015 at 15:48

1 Answer 1

0

You need

pane = FXMLLoader.load(
    ContactManager.class.getResource("/com/techie/java/view/RootLayout.fxml"));

and similarly for the other FXMLLoader.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.