1

My main application runs in a JFXTabPane, having multiple tabs.
In a special case I want to load another AnchorPane on top of the entire application.

RootController.java

JFXTabPane tabPane = new JFXTabPane();

tab = new Tab("Tab 1");
tabPane.getTabs().add(tab);

borderPane.setCenter(tabPane);
loader = new FXMLLoader(getClass().getClassLoader().getResource("fxml1.fxml"));
parent = loader.load();
tab.setContent(parent);
Controller controller = loader.getController();

/* ... Loading more tabs ... */


/* Loading the additional `AnchorPane`, that needs to be loaded at a later point */
AnchorPane pane = FXMLLoader.load(getClass().getClassLoader().getResource("fxml2.fxml"));

Fxml1Controller.java

Pane pane;

/* Registering that AnchorPane in the Controller */
public void setPane(Pane p) {
    this.pane = p;
}

My approach is to set the pane to visible an bring it to front when needed:

private void showPane(ActionEvent event) {
    pane.setVisible(true);
    pane.toFront();
    System.out.println(pane);
}

But it doesn't change anything.

So, how can I display the AnchorPane on top of my JFXTabPane?

Evgenij Reznik
  • 17,916
  • 39
  • 104
  • 181
  • 1
    Add borderPane and pane into StackPane. Show\hide StackPane item depends on condition. – Oleks Jul 05 '19 at 15:30
  • See answers [here](https://stackoverflow.com/questions/8309802/how-can-i-implement-the-functionality-of-awt-cardlayout-in-my-javafx-2-0-applica) – c0der Jul 06 '19 at 04:22

0 Answers0