我正在使用JavaFX 2.2开发一个项目。 我有一个MainPanel,它是一个边框窗格。对于需要显示的每个新面板,它是否设置在mainPanel的中心,因为“标题”/顶部始终保持不变。
示例:
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.
}
}
这是可能的,还是每次初始化新面板时都必须添加包含所有引用的列表?