0

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?

  • Can you edit the code and remove the compile errors? Fix the class name(s), variable declarations, etc. There are too many typos to actually know what you mean here. – James_D Apr 20 '15 at 18:17
  • I editted my code and read the "duplicate" article, but the question over there is not my question. All i want is to know the Controller object of the currently loaded fxml in the center. – Thibault Fouquaert Apr 20 '15 at 18:29

0 Answers0