Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: JavaFX - Issue when including another fxml to a border pane center of a main fxml

  1. #1
    Junior Member
    Join Date
    Dec 2017
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JavaFX - Issue when including another fxml to a border pane center of a main fxml

    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();
    }
    }
    Last edited by GiedriusSt; December 7th, 2017 at 06:57 PM.

Similar Threads

  1. GUI does not stay loaded in applet
    By Techstudent in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 7th, 2013, 02:07 AM
  2. Replies: 5
    Last Post: July 24th, 2012, 12:37 AM
  3. Click and increase size
    By rohit_nik in forum AWT / Java Swing
    Replies: 1
    Last Post: April 4th, 2011, 07:38 AM
  4. Increase heap size; 4 GB wall?
    By BKB in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 13th, 2010, 08:55 PM
  5. Can we increase the stack size for JVM ?
    By prasanna in forum Java Theory & Questions
    Replies: 4
    Last Post: August 4th, 2009, 03:17 PM

Tags for this Thread