1 Replies - 300 Views - Last Post: 07 December 2017 - 04:50 PM Rate Topic: -----

#1 GiedriusSt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-December 17

JavaFX - Included fxml does NOT increase in size when loaded in border

Posted 07 December 2017 - 11:13 AM

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:

Posted Image

This is what I get:

Posted Image

Main FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.effect.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>

<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:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>


<BorderPane fx:id="memberPage" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0" prefWidth="1300.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="GUImembersController">
   <center>
      <TableView BorderPane.alignment="CENTER">
        <columns>
          <TableColumn prefWidth="75.0" text="C1" />
          <TableColumn prefWidth="75.0" text="C2" />
        </columns>
      </TableView>
   </center>
</BorderPane>



Is This A Good Question/Topic? 0
  • +

Replies To: JavaFX - Included fxml does NOT increase in size when loaded in border

#2 GiedriusSt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-December 17

Re: JavaFX - Included fxml does NOT increase in size when loaded in border

Posted 07 December 2017 - 04:50 PM

Forgot to mention the main program:

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();		
	}
}



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1