Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Javafx (Node) getUserDate() or getProperties() returns a none null value and throws NullPointerExece

nye'eJun 28 2014 — edited Jun 28 2014

Hi everyone !

     Here is the code that set the user data:

            FXMLLoader loader = new FXMLLoader(getClass().getResource(page.toString()));

            Parent node = (Parent) loader.load();

            loader.getController().setParent(handler);

            controllers.put(page.name(), loader.getController());

            controller = controllers.get(page.name());

           node.setUserData(page.name());

            node.getProperties().put("page", page.name());


     the variable page is an Enum object, I'm using the name 'page.name()' as the user data

     Here is the code that gets the user data

     while (iterator.hasNext()) {

            Node node = iterator.next();

            String name = node.getProperties().get("page").toString();

            System.out.println(name);

            ....

        }

     now this what happens:

     the System.out.println(name); prints out the user data correctly,

     and then I get a NullPointException pointing to

     String name = node.getProperties().get("page").toString();

    

     the point is System.out.println(name) that prints the user date

     prints it correct.

     pls can some tell me what going on here. Thank!.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 26 2014
Added on Jun 28 2014
2 comments
1,305 views