1

So I am new to JavaFX and from all the tutorials I've watched and apps I've coded, the entire view is created in the FXML file.

I came across ControlsFX and Im trying to implement the popup feature in it. My question here is; How do I set all the components inside a component to load from an external FXML file?

This is what I tried myself but cant get it to work:

    PopOver popOver = new PopOver();
    popOver.setArrowLocation(PopOver.ArrowLocation.RIGHT_CENTER);
    popOver.setContentNode(new Label("Test"));
    popOver.setAutoFix(true);
    popOver.setAutoHide(true);
    popOver.setHideOnEscape(true);
    popOver.setDetachable(false);

    Node content = null;

    FXMLLoader fxmlLoader = new FXMLLoader();
    content = (Parent) fxmlLoader.load(getClass().getResourceAsStream("new.fxml"));
    popOver.setContentNode(content);

    popOver.show(new_button);
Salman Fazal
  • 559
  • 7
  • 22

1 Answers1

1

Okay I figured out a solution just in case it might help someone in the future.

BorderPane p = FXMLLoader.load(getClass().getResource("new.fxml"));
popOver.setContentNode(p);
popOver.show(new_button);
Salman Fazal
  • 559
  • 7
  • 22
  • 1
    Please explain why this worked when your previous code didn't (probably helps to also explain in the question what "doesn't work" means). It's not going to be helpful to other users unless it is clear what the actual issue is this fixes. – James_D Nov 13 '17 at 12:07