I'm working on a project in JavaFX 2.2. I have a MainPanel, which is a border pane. For every new panel that needs to be shown, is this set in the center of the mainPanel, because the 'header'/top stays the same all the time.
example:
public class MainPanelController extends BorderPane {
private StartPanelController StartPanel;
public MainPanelController () {
FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPanel.fxml"));
loader.setRoot(this);
loader.setController(this);
try {
loader.load();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
buildGUI();
}
private void buildGUI() {
StartPanel = new StartPanelController(this);
this.setCenter(StartPanel); //this is the very first screen that is shown within the mainpanel.
private void HeaderItemOnAction(ActionEvent event) {
Node currentCenterPanel = this.getCenter();
//From this node that is currently in the center i would like to know the current controller object.
}
}
is this possible or do i have to add a list with all the references every time a new panel is initialized?