Skip to content

Instantly share code, notes, and snippets.



Last active May 8, 2016
What would you like to do?
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.ToolBar?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.VBox?>
<BorderPane id="BorderPane" prefHeight="400.0" prefWidth="600.0" xmlns="" xmlns:fx="" fx:controller="org.nilsding.j4b.hue02.kurssystem.view.RootLayoutController">
<TabPane fx:id="tabPane" prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" BorderPane.alignment="CENTER">
<Tab fx:id="tabKurse" closable="false" text="Kurse" />
<Tab fx:id="tabDozenten" closable="false" text="Dozenten" />
<VBox BorderPane.alignment="CENTER">
<!-- useSystemMenuBar => use global menu bar on OS X; this fucks up SceneBuilder's menu bar though -->
<MenuBar useSystemMenuBar="true">
<Menu mnemonicParsing="false" text="File">
<MenuItem mnemonicParsing="false" onAction="#handleQuit" text="Quit" />
<Menu mnemonicParsing="false" text="Help">
<MenuItem mnemonicParsing="false" onAction="#handleAbout" text="About" />
<ToolBar prefHeight="40.0" prefWidth="200.0">
<Button fx:id="buttonRefresh" mnemonicParsing="false" onAction="#handleRefresh" text="Refresh" />
public class RootLayoutController {
private MainApp mainApp;
private Tab tabKurse;
private Tab tabDozenten;
private KursOverviewController kursOverviewController;
private DozentOverviewController dozentOverviewController;
* Initializes the controller class.
public void initialize() {
// load tab layouts + controllers
kursOverviewController = loadTab(tabKurse, "KursOverview");
dozentOverviewController = loadTab(tabDozenten, "DozentOverview");
* Loads the contents of the tab <tt>tab</tt>.
* @see
* @author Georg G. <>
* @param tab reference to a JavaFX Tab
* @param name Name of the FXML file without the extension.
private <T> T loadTab(Tab tab, String name) {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(RootLayoutController.class.getResource(name + ".fxml"));
SplitPane content = (SplitPane) loader.load();
T controller = loader.getController();
return controller;
} catch (IOException ex) {
System.out.println("error while loading tab " + name);
return null;
public void setMainApp(MainApp mainApp) {
this.mainApp = mainApp;
// don't forget to set the mainapp in the underlying controllers as well if you need it there
if (kursOverviewController != null) {
if (dozentOverviewController != null) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment