First of all, excuse me if my English is bad, I don't speak English.
So, I'm working with javafx, when I say "dynamic layouts", I refer to the fact that I have my .fxml already programmed with a default structure which it is so.
menu.fxml view
and its code is this
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import java.lang.String?>
<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<AnchorPane prefWidth="356.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<VBox prefHeight="243.0" prefWidth="356.0" spacing="2.0" stylesheets="#../styles/Containers.css" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<AnchorPane prefHeight="31.0" prefWidth="356.0">
<children>
<HBox prefHeight="35.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<children>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true">
<HBox.margin>
<Insets left="10.0" />
</HBox.margin>
<image>
<Image url="#../icons/icons8_Calendar_100px.png" />
</image>
</ImageView>
<Label fx:id="lblFecha" prefHeight="31.0" prefWidth="306.0" stylesheets="#../styles/Strings.css" text="---- ----, -----">
<HBox.margin>
<Insets left="15.0" />
</HBox.margin>
<styleClass>
<String fx:value="h4" />
<String fx:value="principal" />
</styleClass>
</Label>
</children>
</HBox>
</children>
</AnchorPane>
<AnchorPane>
<children>
<HBox prefHeight="35.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../icons/icons8_Clock_100px.png" />
</image>
<HBox.margin>
<Insets left="10.0" />
</HBox.margin>
</ImageView>
<Label fx:id="lblHora" prefHeight="31.0" prefWidth="306.0" stylesheets="#../styles/Strings.css" text="-- : -- : -- --">
<HBox.margin>
<Insets left="15.0" />
</HBox.margin>
<styleClass>
<String fx:value="h4" />
<String fx:value="principal" />
</styleClass>
</Label>
</children>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
</HBox>
</children>
</AnchorPane>
<AnchorPane fx:id="opcParlking">
<children>
<JFXButton alignment="BASELINE_LEFT" graphicTextGap="25.0" onAction="#openParking" prefHeight="35.0" prefWidth="366.0" styleClass="h4" text="Parking" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" translateX="10.0">
<image>
<Image url="#../icons/icons8_Tollbooth_100px.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<stylesheets>
<URL value="#../styles/Buttons.css" />
<URL value="#../styles/Strings.css" />
</stylesheets>
</JFXButton>
</children>
</AnchorPane>
<AnchorPane>
<children>
<JFXButton alignment="BASELINE_LEFT" graphicTextGap="25.0" prefHeight="35.0" prefWidth="363.0" styleClass="h4" text="Tipo de vehiculos" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" translateX="10.0">
<image>
<Image url="#../icons/icons8_Traffic_Jam_96px.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<stylesheets>
<URL value="#../styles/Buttons.css" />
<URL value="#../styles/Strings.css" />
</stylesheets>
</JFXButton>
</children>
</AnchorPane>
<AnchorPane>
<children>
<JFXButton alignment="BASELINE_LEFT" graphicTextGap="25.0" prefHeight="35.0" prefWidth="363.0" styleClass="h4" text="Usuarios" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" translateX="10.0">
<image>
<Image url="#../icons/icons8_User_Groups_100px.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<stylesheets>
<URL value="#../styles/Buttons.css" />
<URL value="#../styles/Strings.css" />
</stylesheets>
</JFXButton>
</children>
</AnchorPane>
<AnchorPane>
<children>
<JFXButton alignment="BASELINE_LEFT" graphicTextGap="25.0" prefHeight="35.0" prefWidth="361.0" styleClass="h4" text="Clientes" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" translateX="10.0">
<image>
<Image url="#../icons/icons8_Helping_Hand_104px.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<stylesheets>
<URL value="#../styles/Buttons.css" />
<URL value="#../styles/Strings.css" />
</stylesheets>
</JFXButton>
</children>
</AnchorPane>
<AnchorPane>
<children>
<JFXButton alignment="BASELINE_LEFT" graphicTextGap="25.0" prefHeight="35.0" prefWidth="361.0" styleClass="h4" text="Reportes" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" translateX="10.0">
<image>
<Image url="#../icons/icons8_Combo_Chart_104px.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<stylesheets>
<URL value="#../styles/Buttons.css" />
<URL value="#../styles/Strings.css" />
</stylesheets>
</JFXButton>
</children>
</AnchorPane>
<AnchorPane>
<children>
<JFXButton alignment="BASELINE_LEFT" graphicTextGap="25.0" prefHeight="29.0" prefWidth="356.0" styleClass="h4" text="Configuraciones" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" translateX="10.0">
<image>
<Image url="#../icons/icons8_Automation_100px.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<stylesheets>
<URL value="#../styles/Buttons.css" />
<URL value="#../styles/Strings.css" />
</stylesheets>
</JFXButton>
</children>
</AnchorPane>
</children>
</VBox>
</children>
</AnchorPane>
I want to be able in my execution time to hide any buttons and that the buttons adjust automatically filling the blank space that the hidden button leaves.
I've tried using in the MenuController.java instructions like opcParlking.setVisible(false) but it leave me a blank space. This the picture imagen 2.
How can I fix this?
You will want to assign an fx:id to your VBox as well and then inject it into your controller:
#FXML
private VBox vBox;
Then, in your controller, instead of setting a node visible or not, just remove it from the VBox:
vBox.getChildren().remove(opcParlking);
This will remove the node entirely, instead of just making it invisible. Therefore, you will not have the empty space.
Related
When I preview my form inside the Scene builder preview window (Window in preview mode) option everything is laid out perfectly like I want it and it is a good size. When I actually run the program (what actually is shown) and click on my button to open this new form, only about 1/4 of my labels and buttons are actually shown unless I make it full screen and everything is far more spaced out than it should be. Anyway advice to fix this?
`
<?import javafx.geometry.*?>
<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
minWidth="-Infinity" prefHeight="1080.0" prefWidth="1920.0"
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="sample.Controller">
<children>
<VBox layoutY="-5.0" prefHeight="811.0" prefWidth="1058.0" spacing="15.0">
<children>
<VBox prefHeight="301.0" prefWidth="488.0" spacing="20.0">
<children>
<Label alignment="TOP_CENTER" contentDisplay="CENTER" text="These are the available options for a 7 day cruise">
<font>
<Font name="System Bold" size="30.0" />
</font>
</Label>
<RadioButton mnemonicParsing="false" text="Interior room ticket $765" />
<RadioButton mnemonicParsing="false" text="Ocean view ticket $810" />
<RadioButton mnemonicParsing="false" text="Balcony ticket $1090" />
<RadioButton mnemonicParsing="false" text="Suite ticket $1560">
<padding>
<Insets top="5.0" />
</padding>
</RadioButton>
<Label text="*Prices shown are prices per person">
<font>
<Font name="System Bold Italic" size="24.0" />
</font>
</Label>
</children>
<padding>
<Insets top="20.0" />
</padding>
</VBox>
<HBox prefHeight="41.0" prefWidth="1895.0" spacing="30.0">
<children>
<CheckBox mnemonicParsing="false" text="VIP discount" />
<CheckBox mnemonicParsing="false" text="Prepaid gratitude" />
</children>
</HBox>
<Label text="Prepaid activites that can be attended by both guests">
<font>
<Font name="System Bold" size="30.0" />
</font>
<padding>
<Insets top="75.0" />
</padding>
</Label>
<HBox prefHeight="314.0" prefWidth="1895.0">
<children>
<VBox prefHeight="419.0" prefWidth="922.0" spacing="20.0">
<children>
<CheckBox mnemonicParsing="false" text="Free Internet" />
<CheckBox mnemonicParsing="false" text="Couples massage" />
<CheckBox mnemonicParsing="false" text="Horse back riding excursion" />
<CheckBox mnemonicParsing="false" text="Fitness Classes" />
<CheckBox mnemonicParsing="false" />
</children>
</VBox>
<VBox prefHeight="477.0" prefWidth="942.0" spacing="20.0">
<children>
<CheckBox mnemonicParsing="false" />
<CheckBox mnemonicParsing="false" />
<CheckBox mnemonicParsing="false" text="Casino Games" />
<CheckBox mnemonicParsing="false" text="Watch a show at the theatre" />
<CheckBox mnemonicParsing="false" text="Game Show" />
</children>
<padding>
<Insets bottom="25.0" />
</padding>
</VBox>
</children>
</HBox>
<Button mnemonicParsing="false" text="Calculate total price" />
</children>
<padding>
<Insets bottom="10.0" left="20.0" />
</padding>
</VBox>
</children>
</AnchorPane>
`
Main Class
I went in and got rid of most of the manual sizes. I would also set the PrimaryStage width to 800 and height to 700 and not allow resizing. Test this out.
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="700.0" maxWidth="800.0" minHeight="700.0" minWidth="800.0" prefHeight="700.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
<children>
<VBox layoutY="-5.0" spacing="15.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<VBox maxHeight="-Infinity" spacing="20.0" VBox.vgrow="ALWAYS">
<children>
<Label alignment="TOP_CENTER" contentDisplay="CENTER" text="These are the available options for a 7 day cruise">
<font>
<Font name="System Bold" size="22.0" />
</font>
</Label>
<RadioButton mnemonicParsing="false" text="Interior room ticket $765">
<font>
<Font size="18.0" />
</font>
<padding>
<Insets left="10.0" />
</padding>
</RadioButton>
<RadioButton mnemonicParsing="false" text="Ocean view ticket $810">
<font>
<Font size="18.0" />
</font>
<padding>
<Insets left="10.0" />
</padding>
</RadioButton>
<RadioButton mnemonicParsing="false" text="Balcony ticket $1090">
<font>
<Font size="18.0" />
</font>
<padding>
<Insets left="10.0" />
</padding>
</RadioButton>
<RadioButton mnemonicParsing="false" text="Suite ticket $1560">
<padding>
<Insets left="10.0" />
</padding>
<font>
<Font size="18.0" />
</font>
</RadioButton>
</children>
</VBox>
<VBox>
<children>
<Label text="*Prices shown are prices per person">
<font>
<Font name="System Bold Italic" size="16.0" />
</font>
</Label>
<HBox spacing="30.0">
<children>
<CheckBox mnemonicParsing="false" text="VIP discount">
<font>
<Font size="15.0" />
</font>
</CheckBox>
<CheckBox mnemonicParsing="false" text="Prepaid gratitude">
<font>
<Font size="15.0" />
</font>
</CheckBox>
</children>
<padding>
<Insets left="10.0" />
</padding>
</HBox>
</children>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="20.0" VBox.vgrow="ALWAYS">
<children>
<Label text="Prepaid activites that can be attended by both guests" VBox.vgrow="ALWAYS">
<font>
<Font name="System Bold" size="22.0" />
</font>
</Label>
<HBox VBox.vgrow="ALWAYS">
<children>
<VBox spacing="20.0" HBox.hgrow="ALWAYS">
<children>
<CheckBox mnemonicParsing="false" text="Free Internet">
<font>
<Font size="15.0" />
</font>
</CheckBox>
<CheckBox mnemonicParsing="false" text="Couples massage">
<font>
<Font size="15.0" />
</font>
</CheckBox>
<CheckBox mnemonicParsing="false" text="Horse back riding excursion">
<font>
<Font size="15.0" />
</font>
</CheckBox>
<CheckBox mnemonicParsing="false" text="Fitness Classes">
<font>
<Font size="15.0" />
</font>
</CheckBox>
<CheckBox mnemonicParsing="false">
<font>
<Font size="15.0" />
</font>
</CheckBox>
</children>
<padding>
<Insets left="10.0" />
</padding>
</VBox>
<VBox spacing="20.0" HBox.hgrow="ALWAYS">
<children>
<CheckBox mnemonicParsing="false">
<font>
<Font size="15.0" />
</font>
</CheckBox>
<CheckBox mnemonicParsing="false">
<font>
<Font size="15.0" />
</font>
</CheckBox>
<CheckBox mnemonicParsing="false" text="Casino Games">
<font>
<Font size="15.0" />
</font>
</CheckBox>
<CheckBox mnemonicParsing="false" text="Watch a show at the theatre">
<font>
<Font size="15.0" />
</font>
</CheckBox>
<CheckBox mnemonicParsing="false" text="Game Show">
<font>
<Font size="15.0" />
</font>
</CheckBox>
</children>
<padding>
<Insets bottom="25.0" />
</padding>
</VBox>
</children>
</HBox>
</children>
<VBox.margin>
<Insets top="30.0" />
</VBox.margin>
</VBox>
<Button mnemonicParsing="false" prefHeight="40.0" text="Calculate total price" />
</children>
<padding>
<Insets bottom="15.0" left="20.0" />
</padding>
</VBox>
</children>
<padding>
<Insets top="15.0" />
</padding>
</AnchorPane>
i never got a erreur like this toggleButtonGroup class does not exist javafx
i searched but didnt found erreur like this
so this is not duplicate questions
thanks
here iy fxml code
<?xml version="1.0" encoding="UTF-8"?>
<?import com.gluonhq.charm.glisten.control.ToggleButtonGroup?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXTextArea?>
<?import com.jfoenix.controls.JFXTextField?>
<?import com.jfoenix.controls.JFXToggleButton?>
<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<AnchorPane id="AnchorPane" maxHeight="568.0" maxWidth="699.0" prefHeight="589.0" prefWidth="699.0" styleClass="mainFxmlClass" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller.AjouterEmployerController">
<stylesheets>
<URL value="#/css/ajouteremployer.css" />
</stylesheets>
<children>
<Pane layoutX="330.0" prefHeight="568.0" prefWidth="15.0" style="-fx-background-color: black;" />
<Separator layoutX="324.0" orientation="VERTICAL" prefHeight="568.0" prefWidth="9.0" />
<Separator layoutX="346.0" orientation="VERTICAL" prefHeight="568.0" prefWidth="1.0" />
<Pane layoutX="-1.0" layoutY="-2.0" prefHeight="568.0" prefWidth="328.0">
<children>
<Separator layoutX="14.0" orientation="VERTICAL" prefHeight="568.0" prefWidth="6.0" />
<Separator layoutX="128.0" orientation="VERTICAL" prefHeight="435.0" prefWidth="6.0" />
<Separator layoutX="285.0" orientation="VERTICAL" prefHeight="568.0" prefWidth="6.0" />
<Label layoutX="30.0" layoutY="15.0" prefHeight="17.0" prefWidth="94.0" text="CNE :" />
<Label layoutX="30.0" layoutY="54.0" prefHeight="17.0" prefWidth="94.0" text="first name" />
<Label layoutX="30.0" layoutY="94.0" prefHeight="17.0" prefWidth="94.0" text="lastname" />
<Label layoutX="30.0" layoutY="168.0" prefHeight="17.0" prefWidth="76.0" text="phone" />
<Label layoutX="30.0" layoutY="209.0" prefHeight="17.0" prefWidth="66.0" text="section" />
<Label layoutX="30.0" layoutY="255.0" text="transporte" />
<Label layoutX="30.0" layoutY="291.0" text="note" />
<JFXTextField fx:id="AddCNE" layoutX="131.0" layoutY="11.0" prefHeight="25.0" prefWidth="152.0" />
<JFXTextField fx:id="AddFirstName" layoutX="131.0" layoutY="50.0" prefHeight="25.0" prefWidth="152.0" />
<JFXTextField fx:id="AddLastName" layoutX="131.0" layoutY="90.0" prefHeight="25.0" prefWidth="152.0" />
<JFXTextField fx:id="AddAge" layoutX="131.0" layoutY="128.0" prefHeight="25.0" prefWidth="152.0" />
<JFXTextField fx:id="AddPhone" layoutX="131.0" layoutY="164.0" prefHeight="25.0" prefWidth="152.0" />
<JFXToggleButton fx:id="AddTransport" layoutX="155.0" layoutY="235.0" prefHeight="56.0" prefWidth="105.0" text="YES" />
<Label layoutX="152.0" layoutY="255.0" prefHeight="17.0" prefWidth="24.0" text="NO" />
<JFXTextArea fx:id="AddNote" layoutX="131.0" layoutY="286.0" prefHeight="131.0" prefWidth="152.0" />
<JFXButton fx:id="AddEmployer" buttonType="RAISED" layoutX="207.0" layoutY="442.0" onAction="#AddEmployerAndSelectEmpolyer" prefHeight="36.0" prefWidth="76.0" ripplerFill="#7ffc7a" style="-fx-background-color: #188616;" text="ADD" textFill="#e5e8eb" />
<Separator layoutX="14.0" layoutY="434.0" prefHeight="3.0" prefWidth="271.0" />
<JFXButton fx:id="resetAll" layoutX="20.0" layoutY="442.0" onAction="#reset" prefHeight="36.0" prefWidth="66.0" ripplerFill="#7ef878" style="-fx-background-color: #188616;" text="reset" textFill="#f0f1f2" />
<Label fx:id="messageAdd" layoutX="25.0" layoutY="497.0" prefHeight="56.0" prefWidth="254.0" textFill="#eb0909e9" wrapText="true" />
<Label layoutX="30.0" layoutY="132.0" prefHeight="17.0" prefWidth="48.0" text="age" />
<ToggleButtonGroup fx:id="SectionValue" layoutX="150.0" layoutY="205.0" selectionType="SINGLE">
<toggles>
<RadioButton fx:id="SectionA" mnemonicParsing="false" prefHeight="17.0" prefWidth="41.0" text="A" />
<RadioButton fx:id="SectionB" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" prefHeight="17.0" prefWidth="45.0" text="B" />
<RadioButton fx:id="sectionC" layoutX="97.0" layoutY="10.0" mnemonicParsing="false" prefHeight="17.0" prefWidth="44.0" text="C" />
</toggles>
</ToggleButtonGroup>
</children>
</Pane>
<VBox layoutX="384.0" layoutY="33.0" prefHeight="459.0" prefWidth="295.0">
<children>
<HBox>
<children>
<Label fx:id="cneEmployer" prefHeight="17.0" prefWidth="88.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
<Label fx:id="cneEmployerValue" prefHeight="17.0" prefWidth="172.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
</children>
</HBox>
<HBox>
<children>
<Label fx:id="firstName" prefHeight="17.0" prefWidth="92.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
<HBox.margin>
<Insets />
</HBox.margin>
</Label>
<Label fx:id="firstNameValue" prefHeight="17.0" prefWidth="208.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
</children>
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</HBox>
<HBox>
<children>
<Label fx:id="latName" prefHeight="17.0" prefWidth="90.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
<Label fx:id="LastNameValue" prefHeight="17.0" prefWidth="196.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
</children>
</HBox>
<HBox>
<children>
<Label fx:id="LabelAge" prefHeight="17.0" prefWidth="135.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
<Label fx:id="LabelAgeValue" prefHeight="17.0" prefWidth="249.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
</children>
</HBox>
<HBox>
<children>
<Label fx:id="num" prefHeight="17.0" prefWidth="110.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
<Label fx:id="phoneValue" prefHeight="17.0" prefWidth="223.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
</children>
</HBox>
<HBox>
<children>
<Label fx:id="sectionn" prefHeight="17.0" prefWidth="113.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
<Label fx:id="Sectionvalue" prefHeight="17.0" prefWidth="221.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
</children>
</HBox>
<HBox>
<children>
<Label fx:id="transportt" prefHeight="17.0" prefWidth="122.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
<Label fx:id="tranportValue" prefHeight="17.0" prefWidth="231.0">
<padding>
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
</children>
</HBox>
<HBox prefHeight="148.0" prefWidth="254.0">
<children>
<Label fx:id="note" prefHeight="148.0" prefWidth="137.0" />
<Label fx:id="noteValue" prefHeight="147.0" prefWidth="256.0" wrapText="true" />
</children>
</HBox>
</children>
</VBox>
</children>
</AnchorPane>
this is the errure
this the second erreur
Try to add the ToggleGroups like this
<VBox>
<RadioButton text="A" fx:id="radioButton1">
<toggleGroup>
<ToggleGroup fx:id="toggleGroup1"/>
</toggleGroup>
</RadioButton>
<RadioButton text="B" toggleGroup="$toggleGroup1" fx:id="radioButton2"/>
</VBox>
I have a GridPane that contains data on a single video, and an ImageView inside it with a columnSpan="3".
I want to get the video image to fit the entire first row perfectly when window size is changing. Any ideas?
This is what I've got so far:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<GridPane fx:id="videoGP" alignment="CENTER" gridLinesVisible="true" prefHeight="315.0" prefWidth="405.0" GridPane.columnIndex="1" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<columnConstraints>
<ColumnConstraints fillWidth="false" halignment="CENTER" hgrow="ALWAYS" maxWidth="30.0" minWidth="10.0" prefWidth="20.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="40.0" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="1000.0" minHeight="10.0" percentHeight="80.0" prefHeight="94.0" valignment="CENTER" vgrow="ALWAYS" />
<RowConstraints maxHeight="37.0" minHeight="0.0" percentHeight="10.0" prefHeight="17.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="31.0" minHeight="10.0" percentHeight="10.0" prefHeight="20.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<ImageView fx:id="videoImage" fitHeight="181.0" fitWidth="364.0" pickOnBounds="true" preserveRatio="true" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS" StackPane.alignment="CENTER">
<image>
<Image url="#../ItTakesTimeToBecomeYoung.jpg" />
</image>
<GridPane.margin>
<Insets />
</GridPane.margin>
</ImageView>
<ImageView fitHeight="25.0" fitWidth="25.0" onMouseClicked="#clickInfo" pickOnBounds="true" preserveRatio="true" GridPane.rowIndex="1" GridPane.rowSpan="2">
<image>
<Image url="#../Views/Icons/bn_info_normal.png" />
</image>
<GridPane.margin>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
</GridPane.margin>
</ImageView>
<Label fx:id="videoName" text="Video Name" GridPane.columnIndex="1" GridPane.rowIndex="1">
<font>
<Font name="System Bold Italic" size="12.0" />
</font>
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
</padding>
</Label>
<Label fx:id="artistName" text="Artist Name" GridPane.columnIndex="1" GridPane.rowIndex="2">
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
</padding>
</Label>
<Label fx:id="videoDuration" alignment="CENTER_RIGHT" prefHeight="13.0" prefWidth="124.0" text="3:49" GridPane.columnIndex="2" GridPane.rowIndex="1">
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
</padding>
</Label>
<ImageView fitHeight="25.0" fitWidth="25.0" onMouseClicked="#clickPlay" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS">
<image>
<Image url="#../Views/Icons/ic_play.png" />
</image>
</ImageView>
</children>
</GridPane>
ImageViews are not resizeable, but you could use a parent that is resizeable and bind the fitWidth and fitHeight properties to the size of the parent using expression binding:
The following example is just a StackPane that could be used as root of a scene to observe the behaviour when resizing the Stage but the same effects would occur, if the StackPane is resized by a Parent, like GridPane:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<StackPane fx:id="root" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ImageView fitWidth="${root.width}" fitHeight="${root.height}" preserveRatio="true">
<!-- ^^ bind to size of node with fx:id="root" ^^ -->
<image>
<Image url="http://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png?v=c78bd457575a"/>
</image>
</ImageView>
</children>
</StackPane>
How to bind an AnchorPane to the size of the screen?
When I run my code it shows me that:
but when the main stage fit the screen the AnchorPane still has the same size.
here is my fxml file
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="768.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sanad.Entry_Page">
<children>
<Pane blendMode="RED" layoutX="563.0" layoutY="9.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="-Infinity" prefHeight="746.0" prefWidth="447.0">
<padding>
<Insets top="10.0" />
</padding>
<children>
<SplitPane dividerPositions="0.5720620842572062" layoutX="-56.0" layoutY="-1.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="741.0" prefWidth="508.0">
<items>
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="751.0" prefWidth="286.0">
<children>
<TextField fx:id="formnumer_field" layoutX="8.0" layoutY="14.0" prefHeight="30.0" prefWidth="235.0" />
<TextField fx:id="sectornumber_field" layoutX="8.0" layoutY="48.0" prefHeight="30.0" prefWidth="235.0" />
<TextField fx:id="fathername_field" layoutX="8.0" layoutY="82.0" prefHeight="30.0" prefWidth="235.0" />
<ComboBox fx:id="fatherborn_year" layoutX="8.0" layoutY="116.0" prefHeight="25.0" prefWidth="70.0" />
<ComboBox fx:id="fatherborn_month" layoutX="85.0" layoutY="116.0" prefHeight="25.0" prefWidth="70.0" />
<ComboBox fx:id="fatherborn_day" layoutX="162.0" layoutY="116.0" prefHeight="25.0" prefWidth="80.0" />
<TextField fx:id="fathercurrentjob" layoutX="8.0" layoutY="145.0" prefHeight="30.0" prefWidth="235.0" />
<TextField fx:id="fatherprevjob" layoutX="8.0" layoutY="179.0" prefHeight="30.0" prefWidth="235.0" />
<TextField fx:id="mothername_field" layoutX="8.0" layoutY="215.0" prefHeight="30.0" prefWidth="235.0" />
<TextField fx:id="mother_curr_job" layoutX="8.0" layoutY="278.0" prefHeight="30.0" prefWidth="235.0" />
<ComboBox fx:id="motherborn_day" layoutX="162.0" layoutY="249.0" prefHeight="25.0" prefWidth="80.0" />
<ComboBox fx:id="motherborn_year" layoutX="8.0" layoutY="249.0" prefHeight="25.0" prefWidth="70.0" />
<TextField fx:id="mother_prev_job" layoutX="8.0" layoutY="312.0" prefHeight="30.0" prefWidth="235.0" />
<ComboBox fx:id="motherborn_month" layoutX="85.0" layoutY="249.0" prefHeight="25.0" prefWidth="70.0" />
<TextField fx:id="homepartner_num" layoutX="8.0" layoutY="346.0" prefHeight="30.0" prefWidth="235.0" />
<ComboBox fx:id="homepartner_year" layoutX="11.0" layoutY="382.0" prefHeight="25.0" prefWidth="70.0" />
<ComboBox fx:id="homepartner_month" layoutX="88.0" layoutY="382.0" prefHeight="25.0" prefWidth="70.0" />
<ComboBox fx:id="homepartner_day" layoutX="163.0" layoutY="382.0" prefHeight="25.0" prefWidth="80.0" />
<ComboBox fx:id="homepartner_name" layoutX="8.0" layoutY="416.0" prefHeight="30.0" prefWidth="235.0" />
<CheckBox fx:id="homepartner_gender1" layoutX="141.0" layoutY="456.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="100.0" text="ذكر">
<font>
<Font size="14.0" />
</font>
</CheckBox>
<CheckBox fx:id="homepartner_gender2" layoutX="8.0" layoutY="456.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="100.0" text="أنثى">
<font>
<Font size="14.0" />
</font>
</CheckBox>
<Label fx:id="current_cityaa" alignment="CENTER" layoutX="141.0" layoutY="490.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="100.0" text="المحافظة">
<font>
<Font size="14.0" />
</font>
</Label>
<TextField fx:id="current_city" layoutX="8.0" layoutY="490.0" prefHeight="30.0" prefWidth="120.0" />
<Label fx:id="current_cityaa1" alignment="CENTER" layoutX="141.0" layoutY="530.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="100.0" text="الحي">
<font>
<Font size="14.0" />
</font>
</Label>
<TextField fx:id="current_suberb" layoutX="8.0" layoutY="530.0" prefHeight="30.0" prefWidth="120.0" />
<TextField fx:id="prev_suberb" layoutX="11.0" layoutY="615.0" prefHeight="30.0" prefWidth="120.0" />
<Label fx:id="current_cityaa11" alignment="CENTER" layoutX="144.0" layoutY="615.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="100.0" text="الحي">
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="current_cityaa2" alignment="CENTER" layoutX="144.0" layoutY="575.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="100.0" text="المحافظة">
<font>
<Font size="14.0" />
</font>
</Label>
<TextField fx:id="prev_city" layoutX="11.0" layoutY="575.0" prefHeight="30.0" prefWidth="120.0" />
</children>
</AnchorPane>
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<Label fx:id="formnumber" contentDisplay="RIGHT" layoutX="8.0" layoutY="14.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="174.0" text="رقم الاستمارة" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<padding>
<Insets left="50.0" />
</padding>
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="sectornumber" contentDisplay="RIGHT" layoutX="8.0" layoutY="48.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="174.0" text="رقم القطاع" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="fathername" contentDisplay="RIGHT" layoutX="8.0" layoutY="82.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="174.0" text="اسم الأب" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="fatherborn" contentDisplay="RIGHT" layoutX="20.0" layoutY="112.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="المواليد" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="currentjob" contentDisplay="RIGHT" layoutX="20.0" layoutY="142.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="العمل الحالي" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="previousjob" contentDisplay="RIGHT" layoutX="20.0" layoutY="172.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="العمل السابق" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="fatherborn1" contentDisplay="RIGHT" layoutX="20.0" layoutY="244.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="المواليد" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="currentjob1" contentDisplay="RIGHT" layoutX="20.0" layoutY="278.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="العمل الحالي" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="fathername1" contentDisplay="RIGHT" layoutX="8.0" layoutY="208.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="174.0" text="اسم الأم" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="previousjob1" contentDisplay="RIGHT" layoutX="20.0" layoutY="307.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="العمل السابق" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="homepartner_sex" contentDisplay="RIGHT" layoutX="20.0" layoutY="451.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="الجنس" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="homepartner_name" contentDisplay="RIGHT" layoutX="20.0" layoutY="414.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="الاسم" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="partner_born" contentDisplay="RIGHT" layoutX="20.0" layoutY="378.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="الميلاد" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="home_partner" contentDisplay="RIGHT" layoutX="8.0" layoutY="341.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="174.0" text="عدد المستضافين" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label alignment="CENTER" layoutX="8.0" layoutY="485.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="175.0" text="السكن الحالي">
<font>
<Font size="14.0" />
</font>
</Label>
<Label alignment="CENTER" layoutX="8.0" layoutY="570.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="175.0" text="السكن الحالي">
<font>
<Font size="14.0" />
</font>
</Label>
</children>
</AnchorPane>
</items>
</SplitPane>
</children>
</Pane>
<SplitPane dividerPositions="0.4845360824742268" layoutX="8.0" layoutY="8.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="741.0" prefWidth="487.0">
<items>
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" />
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="327.0" prefWidth="100.0" />
</items>
</SplitPane>
</children>
</AnchorPane>
This can be done using this property of AnchorPane:
AnchorPane.bottomAnchor
AnchorPane.leftAnchor
AnchorPane.rightAnchor
AnchorPane.topAnchor
But you need to decide what part of a scene will change and what is not. The width of the fixed part fix with prefWidth. Сhanging part fix with AnchorPane.leftAnchor or AnchorPane.rightAnchor given the size of the fixed part.
Sample:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sanad.Entry_Page">
<children>
<Accordion prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<panes>
<TitledPane animated="false" text="untitled 1">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</TitledPane>
<TitledPane animated="false" text="untitled 2">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</TitledPane>
<TitledPane animated="false" text="untitled 3">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</TitledPane>
</panes>
</Accordion>
<SplitPane dividerPositions="0.5" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="200.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<LineChart AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</LineChart>
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<TableView prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columns>
<TableColumn prefWidth="75.0" text="C1" />
<TableColumn prefWidth="75.0" text="C2" />
</columns>
</TableView>
</children>
</AnchorPane>
</items>
</SplitPane>
</children>
</AnchorPane>
I try do something with this fxml, but i think that is bad created. You should rebuild everything. For right site is better to use GridPane not AnchorPane and put all elements in grid.
I created HBox in this hobx I put two AnchorPane, then each AnchorPane i put Your SplitPane. After this you must connect each SplitPane with right and left edge of AnchorPane like this:
<SplitPane AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
Here is this fxml:
Use SceneBuilder to preview how it works.
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<HBox id="AnchorPane" prefHeight="786.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<AnchorPane prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS">
<children>
<SplitPane dividerPositions="0.4845360824742268" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="741.0" prefWidth="487.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<items>
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" />
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="327.0" prefWidth="100.0" />
</items>
</SplitPane>
</children>
</AnchorPane>
<AnchorPane prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS">
<children>
<SplitPane dividerPositions="0.5720620842572062" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="741.0" prefWidth="508.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<items>
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" nodeOrientation="LEFT_TO_RIGHT">
<children>
<TextField fx:id="formnumer_field" layoutX="8.0" layoutY="14.0" prefHeight="30.0" prefWidth="235.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="43.0" />
<TextField fx:id="sectornumber_field" layoutX="8.0" layoutY="48.0" prefHeight="30.0" prefWidth="235.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="43.0" />
<TextField fx:id="fathername_field" layoutX="8.0" layoutY="82.0" prefHeight="30.0" prefWidth="235.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="43.0" />
<ComboBox fx:id="fatherborn_year" layoutX="8.0" layoutY="116.0" prefHeight="25.0" prefWidth="70.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="226.0" />
<ComboBox fx:id="fatherborn_month" layoutX="85.0" layoutY="116.0" prefHeight="25.0" prefWidth="70.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="226.0" />
<ComboBox fx:id="fatherborn_day" layoutX="162.0" layoutY="116.0" prefHeight="25.0" prefWidth="80.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="226.0" />
<TextField fx:id="fathercurrentjob" layoutX="8.0" layoutY="145.0" prefHeight="30.0" prefWidth="235.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="72.0" />
<TextField fx:id="fatherprevjob" layoutX="8.0" layoutY="179.0" prefHeight="30.0" prefWidth="235.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="72.0" />
<TextField fx:id="mothername_field" layoutX="8.0" layoutY="215.0" prefHeight="30.0" prefWidth="235.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="72.0" />
<TextField fx:id="mother_curr_job" layoutX="8.0" layoutY="278.0" prefHeight="30.0" prefWidth="235.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="72.0" />
<ComboBox fx:id="motherborn_day" layoutX="162.0" layoutY="249.0" prefHeight="25.0" prefWidth="80.0" AnchorPane.rightAnchor="73.0" />
<ComboBox fx:id="motherborn_year" layoutX="8.0" layoutY="249.0" prefHeight="25.0" prefWidth="70.0" />
<TextField fx:id="mother_prev_job" layoutX="8.0" layoutY="312.0" prefHeight="30.0" prefWidth="235.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="72.0" />
<ComboBox fx:id="motherborn_month" layoutX="85.0" layoutY="249.0" nodeOrientation="LEFT_TO_RIGHT" />
<TextField fx:id="homepartner_num" layoutX="8.0" layoutY="346.0" prefHeight="30.0" prefWidth="235.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="72.0" />
<ComboBox fx:id="homepartner_year" layoutX="11.0" layoutY="382.0" />
<ComboBox fx:id="homepartner_month" layoutX="88.0" layoutY="382.0" />
<ComboBox fx:id="homepartner_day" layoutX="163.0" layoutY="382.0" />
<ComboBox fx:id="homepartner_name" layoutX="8.0" layoutY="416.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="72.0" />
<CheckBox fx:id="homepartner_gender1" layoutX="141.0" layoutY="456.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="100.0" text="ذكر">
<font>
<Font size="14.0" />
</font>
</CheckBox>
<CheckBox fx:id="homepartner_gender2" layoutX="8.0" layoutY="456.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="100.0" text="أنثى">
<font>
<Font size="14.0" />
</font>
</CheckBox>
<Label fx:id="current_cityaa" alignment="CENTER" layoutX="141.0" layoutY="490.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="100.0" text="المحافظة" AnchorPane.rightAnchor="74.0">
<font>
<Font size="14.0" />
</font>
</Label>
<TextField fx:id="current_city" layoutX="8.0" layoutY="490.0" AnchorPane.leftAnchor="8.0" />
<Label fx:id="current_cityaa1" alignment="CENTER" layoutX="141.0" layoutY="530.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="100.0" text="الحي" AnchorPane.rightAnchor="74.0">
<font>
<Font size="14.0" />
</font>
</Label>
<TextField fx:id="current_suberb" layoutX="8.0" layoutY="530.0" AnchorPane.leftAnchor="8.0" />
<TextField fx:id="prev_suberb" layoutX="11.0" layoutY="615.0" AnchorPane.leftAnchor="11.0" />
<Label fx:id="current_cityaa11" alignment="CENTER" layoutX="144.0" layoutY="615.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="100.0" text="الحي" AnchorPane.rightAnchor="71.0">
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="current_cityaa2" alignment="CENTER" layoutX="144.0" layoutY="575.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="100.0" text="المحافظة" AnchorPane.rightAnchor="71.0">
<font>
<Font size="14.0" />
</font>
</Label>
<TextField fx:id="prev_city" layoutX="11.0" layoutY="575.0" AnchorPane.leftAnchor="11.0" />
</children>
</AnchorPane>
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<Label fx:id="formnumber" contentDisplay="RIGHT" layoutX="8.0" layoutY="14.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="174.0" text="رقم الاستمارة" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<padding>
<Insets left="50.0" />
</padding>
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="sectornumber" contentDisplay="RIGHT" layoutX="8.0" layoutY="48.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="174.0" text="رقم القطاع" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="fathername" contentDisplay="RIGHT" layoutX="8.0" layoutY="82.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="174.0" text="اسم الأب" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="fatherborn" contentDisplay="RIGHT" layoutX="20.0" layoutY="112.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="المواليد" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="currentjob" contentDisplay="RIGHT" layoutX="20.0" layoutY="142.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="العمل الحالي" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="previousjob" contentDisplay="RIGHT" layoutX="20.0" layoutY="172.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="العمل السابق" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="fatherborn1" contentDisplay="RIGHT" layoutX="20.0" layoutY="244.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="المواليد" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="currentjob1" contentDisplay="RIGHT" layoutX="20.0" layoutY="278.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="العمل الحالي" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="fathername1" contentDisplay="RIGHT" layoutX="8.0" layoutY="208.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="174.0" text="اسم الأم" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="previousjob1" contentDisplay="RIGHT" layoutX="20.0" layoutY="307.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="العمل السابق" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="homepartner_sex" contentDisplay="RIGHT" layoutX="20.0" layoutY="451.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="الجنس" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="homepartner_name" contentDisplay="RIGHT" layoutX="20.0" layoutY="414.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="الاسم" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="partner_born" contentDisplay="RIGHT" layoutX="20.0" layoutY="378.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="127.0" text="الميلاد" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label fx:id="home_partner" contentDisplay="RIGHT" layoutX="8.0" layoutY="341.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="174.0" text="عدد المستضافين" textAlignment="RIGHT" textOverrun="CENTER_ELLIPSIS">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="50.0" />
</padding>
</Label>
<Label alignment="CENTER" layoutX="8.0" layoutY="485.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="175.0" text="السكن الحالي">
<font>
<Font size="14.0" />
</font>
</Label>
<Label alignment="CENTER" layoutX="8.0" layoutY="570.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="30.0" prefWidth="175.0" text="السكن الحالي">
<font>
<Font size="14.0" />
</font>
</Label>
</children>
</AnchorPane>
</items>
</SplitPane>
<Pane blendMode="RED" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="-Infinity" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<padding>
<Insets top="10.0" />
</padding>
</Pane>
</children>
</AnchorPane>
</HBox>
When I am having data in the tableview (which is custom component), then horizontal scrollbar is visible, but if there will no data and only columns are there then scroll-bar is not visible.
Is it because of custom component I made or my FXML needs some changes.
FXML
<AnchorPane stylesheets="prj.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" >
<children>
<ScrollPane fitToHeight="true" fitToWidth="true" VBox.vgrow="ALWAYS">
<content>
<prjTableView minWidth="500.0" maxWidth="500.0" prefWidth="500.0" VBox.vgrow="ALWAYS" fx:id="treeTableView" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<styleClass>
<String fx:value="k-table-view" />
<String fx:value="redBorder" />
</styleClass>
</prjTreeTableView>
</content>
</ScrollPane>
<HBox alignment="BASELINE_LEFT">
<children>
<HBox>
<children>
<Label text="Page Size">
<HBox.margin>
<Insets left="2.0" top="5.0" />
</HBox.margin>
</Label>
<TextField fx:id="itemsPerPage" maxWidth="-Infinity"
minWidth="-Infinity" prefHeight="22.0" prefWidth="40.0" text="50">
<HBox.margin>
<Insets left="8.0" top="6.0" />
</HBox.margin>
<tooltip>
<Tooltip text="Enter desired page number" />
</tooltip>
</TextField>
<Pagination fx:id="pagination" maxWidth="-Infinity"
minWidth="-Infinity" prefHeight="42.0" prefWidth="235.0"
translateX="1.0" translateY="1.0">
<HBox.margin>
<Insets />
</HBox.margin>
</Pagination>
<Label fx:id="displayInfo">
<HBox.margin>
<Insets top="5.0" />
</HBox.margin>
</Label>
</children>
</HBox>
</children>
</HBox>
</children>
</VBox>
</children>
</AnchorPane>