0

What I am trying to do: I have menu and and after click I am trying to remove unnecessary TextFields. What I did: I used this example: "In JavaFX, nodes can simply be removed from a Parent (e.g. an AnchorPane) using .getChildren() following by .remove(Object o)

AnchorPane ap;
ap.getChildren().remove(btn);

I tried to use:

FXMLLoader load=new FXMLLoader(getClass().getResource("LoginRegister.fxml"));
Parent root = load.load();
root.getChildren();

But my root does not have getChildren() function. Where could be the problem?

Thank you in advance.

EDIT: FOUND THE ANSWER HERE: How to access UI components from SceneBuilder in JavaFX

WHAT I DID WRONG: I USED IN FXML FILE AND IN CONTROLLER DIFFERENT FX:ID's

  • Found the answer, if someone needs: https://stackoverflow.com/questions/29463176/how-to-access-ui-components-from-scenebuilder-in-javafx – Mantas Nacickas Oct 19 '19 at 17:31
  • 1
    `Parent` does have a `getChildren()` method but it has `protected` access. You need to use a more specific type that exposes that method publicly, such as `Group` or `Pane`. – Slaw Oct 20 '19 at 01:54

0 Answers0