I'm trying to include an additional fxml in a main fxml, border pane center. When I do this, the fxml gets included and shows in the center, but the fxml does not occupy the full width and height of the main fxml window.
In the SceneBuilder, if I add the TableView in the center of the borderpane, it acts as it should. Only when I include the fxml via code it does not.
Please help, what am I missing? Any help will be appreciated!
This is what I need:
58Tl9.jpg
This is what I get:
plrHO.jpg
Main FXML:
<TabPane fx:id="TabPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1300.0" tabClosingPolicy="UNAVAILABLE" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<tabs>
<Tab fx:id="lecturersTab" closable="false" text="Lecturers">
<content>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<center>
<TableView prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<columns>
<TableColumn prefWidth="75.0" text="C1" />
<TableColumn prefWidth="75.0" text="C2" />
</columns>
</TableView>
</center>
</BorderPane>
</content>
</Tab>
<Tab fx:id="membersTab" closable="false" text="Members">
<content>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<center>
<fx:include fx:id="memberPage" source="GUImembers.fxml"/>
</center>
</BorderPane>
</content>
</Tab>
</tabs>
</TabPane>
FXML I want to add:
<BorderPane fx:id="memberPage" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="1000.0" prefWidth="1600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="GUImembersController">
<left>
<VBox prefHeight="200.0" prefWidth="300.0" BorderPane.alignment="CENTER" />
</left>
<right>
<VBox prefHeight="200.0" prefWidth="300.0" BorderPane.alignment="CENTER" />
</right>
<center>
<ScrollPane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<content>
<TableView prefHeight="1002.0" prefWidth="1003.0">
<columns>
<TableColumn prefWidth="75.0" text="C1" />
<TableColumn prefWidth="75.0" text="C2" />
</columns>
</TableView>
</content>
</ScrollPane>
</center>
</BorderPane>
Main:
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class MainClass extends Application
{
public FXMLLoader loader;
public static void main(String[] args)
{
launch(args);
}
public void start(Stage stage) throws Exception
{
loader = new FXMLLoader();
loader.setLocation(getClass().getResource("FXML/GUImain.fxml"));
loader.setController(new GUImainController());
Parent root = loader.load();
Scene scene = new Scene(root);
stage.setTitle("VIA - Event Management System");
stage.setScene(scene);
stage.show();
}
}