I cant parse text from the JavaFX TextArea and TextField [duplicate] - javafx

This question already has answers here:
Canvas pane doesn't refreshing(JavaFX) [closed]
(1 answer)
Is #FXML needed for every declaration?
(3 answers)
Closed 7 days ago.
I am using the JavaFX as my GUI and JDBC as my API for database. The method saveCard() is supposed to parse text from the JavaFX TextArea and TextField which then saves the data through the database.insertQuestionAndAnswer() method. It is not and only returning an empty string.
Java code:
package workspace;
import java.io.IOException;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
public class CardMakerController {
#FXML
private CardDatabase database = new CardDatabase();
private TextField questionContainer = new TextField();
private TextArea answerContainer = new TextArea();
public void changeViewToDefaultScreen(ActionEvent e) throws IOException {
App.setRootForScene("welcomeScreen");
}
public void saveCard() {
String cardQuestion = questionContainer.getText();
String cardAnswer = answerContainer.getText();
System.out.println("cardQuestion" + cardAnswer);
database.insertQuestionAndAnswer(cardQuestion, cardAnswer);
}
}
FXML file:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>
<GridPane prefHeight="373.0" prefWidth="579.0" style="-fx-background-color: khaki; -fx-border-color: orange;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="workspace.CardMakerController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="CREATE FLASH CARD" textAlignment="CENTER" wrapText="true" GridPane.columnIndex="2">
<font>
<Font name="Cascadia Code Regular" size="12.0" />
</font>
</Label>
<Label text="QUESTION:" GridPane.columnIndex="1" GridPane.rowIndex="1" GridPane.valignment="TOP">
<font>
<Font name="Cascadia Code Regular" size="12.0" />
</font>
</Label>
<Label text="ANSWER/S:" GridPane.columnIndex="1" GridPane.rowIndex="2" GridPane.valignment="BOTTOM">
<font>
<Font name="Cascadia Code Regular" size="12.0" />
</font>
<GridPane.margin>
<Insets bottom="12.0" />
</GridPane.margin>
</Label>
<TextField fx:id="questionContainer" prefHeight="25.0" prefWidth="125.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="1" GridPane.valignment="BOTTOM" />
<TextArea fx:id="answerContainer" prefHeight="70.0" prefWidth="348.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="3" GridPane.rowSpan="2" />
<DialogPane style="-fx-background-color: KHAKI;" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="5" />
<Button mnemonicParsing="false" onAction="#saveCard" style="-fx-background-color: orange;" text="Save Card" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="5" GridPane.valignment="CENTER">
<font>
<Font name="Cascadia Code Regular" size="12.0" />
</font>
</Button>
<Button mnemonicParsing="false" onAction="#changeViewToDefaultScreen" style="-fx-background-color: orange;" text="Change View" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="5" GridPane.valignment="CENTER">
<font>
<Font name="Cascadia Code Regular" size="12.0" />
</font>
</Button>
</children>
</GridPane>
I tried to check if the String parsed is null through an if loop to test it, but is not. When I check the database there is no word that is saved. It is empty pleas help

Related

same popup with different style

I want to create three pop-up windows in JavaFX. These windows are almost the same, but they differ in styles. For example, the user deletion window has a black title field, green to activate the user, and red to block. I want to create only one such window in FXML, and then pass the styles as a parameter. How can I do this and is this even possible?
you can either create a custom dialog window or use javafx native dialog window
---------------here i i have created a custom dialog window and i change the colors and icons dynamically as i need
-------FXML-------------------
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?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.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>
<GridPane xmlns:fx="http://javafx.com/fxml/1" style="-fx-border-color: red;" xmlns="http://javafx.com/javafx/8.0.141">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="194.0" minHeight="10.0" prefHeight="117.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="113.0" minHeight="10.0" prefHeight="113.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<AnchorPane prefHeight="113.0" prefWidth="400.0" style="-fx-background-color: e34c5e;">
<children>
<ImageView fitHeight="82.0" fitWidth="104.0" layoutX="153.0" layoutY="18.0" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="17.0" AnchorPane.leftAnchor="153.0" AnchorPane.rightAnchor="165.0" AnchorPane.topAnchor="18.0">
<image>
<Image url="#../Images/eror_icon.png" />
</image>
</ImageView>
</children></AnchorPane>
<AnchorPane layoutX="10.0" layoutY="10.0" prefHeight="129.0" prefWidth="400.0" style="-fx-background-color: white;" GridPane.rowIndex="1">
<children>
<GridPane layoutX="84.0" layoutY="-5.0" prefHeight="99.0" prefWidth="400.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="43.0" minHeight="10.0" prefHeight="39.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="27.0" minHeight="10.0" prefHeight="22.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="36.0" minHeight="10.0" prefHeight="36.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label alignment="CENTER" contentDisplay="CENTER" prefHeight="50.0" prefWidth="401.0" text="Item Not Selected !">
<font>
<Font name="System Bold" size="19.0" />
</font>
</Label>
<Label alignment="CENTER" layoutX="10.0" layoutY="43.0" prefHeight="50.0" prefWidth="401.0" text="Item to Purchase Is Not Selected..Select an Item" GridPane.rowIndex="1" />
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" GridPane.rowIndex="2">
<children>
<JFXButton fx:id="btnOk" buttonType="RAISED" onMouseClicked="#btnOkClicked" prefHeight="32.0" prefWidth="121.0" style="-fx-background-color: e34c5e; -fx-background-radius: 80;" text="Ok" textFill="WHITE">
<HBox.margin>
<Insets bottom="2.0" top="2.0" />
</HBox.margin>
<font>
<Font name="System Bold" size="15.0" />
</font>
</JFXButton>
</children>
</HBox>
</children>
</GridPane>
</children>
</AnchorPane>
</children>
</GridPane>
--------------------Controller--------
package Controllers;
import javafx.scene.control.Dialog;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
public class CustomAlertDialogBox {
private Dialog currentDialog;
public CustomAlertDialogBox(Dialog dialog) {
this.currentDialog = dialog;
}
public void btnOkClicked(MouseEvent mouseEvent) {
Stage stage = (Stage) currentDialog.getDialogPane().getScene().getWindow();
stage.close();
}
}
check this for native dialog box
http://code.makery.ch/blog/javafx-dialogs-official/

JavaFX abstract controller inheritance didn't work

I have a big problem while coding my application.
Well, I try to extend my ReaderController class, which is abstract and it is set as controller in my fxml file.
There is my code:
public abstract class ReaderController extends AnchorPane{
#FXML
TextField id;
#FXML
TextField name;
#FXML
TextField surname;
#FXML
TextField PESEL;
#FXML
TextField dateOfBirth;
#FXML
TextField documentType;
#FXML
TextField documentNumber;
#FXML
TextField email;
#FXML
TextField phoneNumber;
#FXML
TextField street;
#FXML
TextField city;
#FXML
Button addReader;
Parent root;
public ReaderController()
{
}
And there is my subclass:
public class EditReaderController extends ReaderController{
public EditReaderController() throws IOException
{
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/AddUser.fxml"));
root= (Parent) loader.load();
loader.setController(this);
Stage stage = new Stage();
stage.setTitle("Edit User");
stage.setScene(new Scene(root));
stage.setResizable(false);
stage.show();
}
public void initialize(){
addReader.setText("Edit!");
id.setText(String.valueOf(SQLController.getInstance().getLastIndexOfReader()));
}
I have an error:
aused by: java.lang.InstantiationException
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:927)
... 75 more
So how can I extend my abstract controller into my EditReaderController ?
UPD 1 my fxml file
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/9" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.library.controllers.ReaderController">
<children>
<HBox layoutX="151.0" layoutY="64.0" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<VBox prefHeight="400.0" prefWidth="129.0">
<children>
<GridPane prefHeight="300.0" prefWidth="129.0">
<columnConstraints>
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Nr czytelnika" />
<Label text="ImiÄ™" GridPane.rowIndex="1" />
<Label text="Nazwisko" GridPane.rowIndex="2" />
<Label text="PESEL" GridPane.rowIndex="3" />
<Label text="Data urodzenia" GridPane.rowIndex="4" />
</children>
<VBox.margin>
<Insets top="15.0" />
</VBox.margin>
</GridPane>
</children>
</VBox>
<VBox prefHeight="400.0" prefWidth="178.0">
<children>
<GridPane prefHeight="300.0" prefWidth="178.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextField fx:id="id" editable="false" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="26.0" prefWidth="34.0" />
<TextField fx:id="name" GridPane.rowIndex="1">
<GridPane.margin>
<Insets right="25.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="surname" GridPane.rowIndex="2">
<GridPane.margin>
<Insets right="25.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="PESEL" GridPane.rowIndex="3">
<GridPane.margin>
<Insets right="25.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="dateOfBirth" editable="false" GridPane.rowIndex="4">
<GridPane.margin>
<Insets right="25.0" />
</GridPane.margin>
</TextField>
</children>
<VBox.margin>
<Insets top="15.0" />
</VBox.margin>
</GridPane>
</children>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<GridPane prefHeight="300.0" prefWidth="99.0">
<columnConstraints>
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Typ dokumentu" />
<Label text="Nr dokumentu" GridPane.rowIndex="1" />
<Label text="E-mail" GridPane.rowIndex="2" />
<Label text="Nr telefonu" GridPane.rowIndex="3" />
<Label text="Ulica" GridPane.rowIndex="4" />
<Label text="Miasto" GridPane.rowIndex="5" />
</children>
<VBox.margin>
<Insets top="15.0" />
</VBox.margin>
</GridPane>
</children>
</VBox>
<VBox prefHeight="400.0" prefWidth="195.0">
<children>
<GridPane prefHeight="300.0" prefWidth="195.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextField fx:id="documentType">
<GridPane.margin>
<Insets right="25.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="documentNumber" GridPane.rowIndex="1">
<GridPane.margin>
<Insets right="25.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="email" GridPane.rowIndex="2">
<GridPane.margin>
<Insets right="25.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="phoneNumber" GridPane.rowIndex="3">
<GridPane.margin>
<Insets right="25.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="street" GridPane.rowIndex="4">
<GridPane.margin>
<Insets right="25.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="city" GridPane.rowIndex="5">
<GridPane.margin>
<Insets right="25.0" />
</GridPane.margin>
</TextField>
</children>
<VBox.margin>
<Insets top="15.0" />
</VBox.margin>
</GridPane>
<Button fx:id="addReader" alignment="CENTER" mnemonicParsing="false" onAction="#onAddReaderAction" text="Dodaj" textAlignment="CENTER">
<VBox.margin>
<Insets left="100.0" top="25.0" />
</VBox.margin>
</Button>
</children>
</VBox>
</children>
</HBox>
</children>
</AnchorPane>
Why are you using an abstract class in your fxml?
Look at this line:
fx:controller="com.library.controllers.ReaderController"
You have a non-abstract subclass. Why not use it?
fx:controller="com.library.controllers.EditReaderController"
Or use your own non-abstract class.
I didn't see any abstract members in ReaderController.
Removing the abstract modifier may also solve this.
Also, it's really confusing that your controller class is extending AnchorPane..
Also, according to #sillyfly in the comments,
there really isn't much use calling setController after the call to FXMLLoader#load, as by this point the fields have been injected... I think it would even raise an exception about the controller already being set...
According to the comment,
I know it, but i didn't know, how to set a new Controller through action ( for example clicked Edit or Add button)
You should first read https://docs.oracle.com/javafx/2/ui_controls/button.htm to know how to run some code when a button is clicked, and run
loader.setController(your new controller);
when your button is clicked, and remove the fx:controller field, because you already set the controller in your logic code.

visible button in grid

my gridpane is :
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="569.0" prefWidth="794.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="com.controller.test">
<children>
<GridPane layoutX="10.0" layoutY="270.0" prefWidth="775.0" rotate="0.0">
<children>
<Button fx:id="btn1" mnemonicParsing="false" prefWidth="67.0" rotate="0.0" text="btn1" GridPane.columnIndex="0" GridPane.rowIndex="0" />
<Button fx:id="btn2" mnemonicParsing="false" prefWidth="67.0" rotate="0.0" text="btn2" GridPane.columnIndex="1" GridPane.rowIndex="0" />
<Button fx:id="btn3" mnemonicParsing="false" prefWidth="67.0" rotate="0.0" text="btn3" GridPane.columnIndex="2" GridPane.rowIndex="0" />
<Button fx:id="btn4" mnemonicParsing="false" prefWidth="67.0" rotate="0.0" text="btn4" GridPane.columnIndex="3" GridPane.rowIndex="0" />
</children>
<columnConstraints>
<ColumnConstraints maxWidth="594.0" minWidth="10.0" prefWidth="69.0" />
<ColumnConstraints maxWidth="594.0" minWidth="10.0" prefWidth="69.0" />
<ColumnConstraints maxWidth="558.0" minWidth="10.0" prefWidth="67.0" />
<ColumnConstraints maxWidth="507.0" minWidth="10.0" prefWidth="507.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
</children>
</AnchorPane>
i need the result like below image when visible(false) for btn1,btn2
i use scene builder. thanks
In addition to making the components invisible by setting the visible property to false ('visible="false"'), you have set the managed property to false (managed="false").But with explicit 'ColumnConstraints' in your fxml, 'managed=false' will not have effect. So you may want to avoid using ColumnConstraints and instead use GridPane child component's properties to set dimensions.

How to get same vertical size of TitledPanes in a Gridpane? (JavaFX, Scenebuilder)

i have a problem with the vertical size of the right TiteldPane (see picture below). Both TitledPanes are put in a GridPane. I want that the smaller one gets the same height like the left one. I tried to set the Vgrow to "always" of the right TitledPane, but nothing happened. Also i tried to do something with a Region without a success. Is this possible without giving them an absolut height?
Thanks for your help in advance.
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<AnchorPane xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ScrollPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<AnchorPane>
<children>
<GridPane hgap="20.0" vgap="20.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" />
<ColumnConstraints hgrow="SOMETIMES" />
</columnConstraints>
<rowConstraints>
<RowConstraints valignment="TOP" vgrow="ALWAYS" />
</rowConstraints>
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</padding>
<children>
<TitledPane animated="false" text="TitledPane">
<content>
<GridPane hgap="10.0" vgap="5.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Label" GridPane.halignment="RIGHT" />
<Label GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Label" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
<Label GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label text="Label" GridPane.halignment="RIGHT" GridPane.rowIndex="4" />
<Label GridPane.columnIndex="1" GridPane.rowIndex="5" />
<TextField GridPane.columnIndex="1" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="2" />
<TextField fx:id="abgar10TF" GridPane.columnIndex="1" GridPane.rowIndex="4" />
</children>
</GridPane>
</content>
</TitledPane>
<TitledPane animated="false" text="TitledPane" GridPane.columnIndex="1" GridPane.valignment="TOP" GridPane.vgrow="ALWAYS">
<content>
<GridPane hgap="10.0" vgap="5.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Label" GridPane.halignment="RIGHT" />
<Label GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Label" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
<Label GridPane.columnIndex="1" GridPane.rowIndex="3" />
<TextField GridPane.columnIndex="1" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="2" />
</children>
</GridPane>
</content>
</TitledPane>
</children>
</GridPane>
</children>
</AnchorPane>
</content>
</ScrollPane>
</children>
</AnchorPane>
You have to set max height for both TitlePanes to MAX_VALUE

How to add datepicker field like TextField, Label etc. in the .FXML file (JavaFX)

I am trying to add datepicker field in .fxml (JavaFX). But I don't what is correct way to do?
Please help me how to add datepicker field in .fxml file.
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.collections.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" prefHeight="705.9998779296875" prefWidth="499.9998779296875" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="processbuilder.controler.NewActivityController">
<children>
<GridPane prefHeight="615.9998779296875" prefWidth="499.9998779296875" AnchorPane.bottomAnchor="90.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label prefHeight="24.0" prefWidth="53.0" text="Name : " GridPane.columnIndex="0" GridPane.halignment="CENTER" GridPane.rowIndex="0" GridPane.valignment="CENTER" />
<Label text="Description :" translateY="30.0" GridPane.columnIndex="0" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="TOP" />
<TextField fx:id="name" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="0" />
<TextArea fx:id="desc" prefWidth="200.0" wrapText="true" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="177.0" minWidth="10.0" prefWidth="76.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="394.0" minWidth="10.0" prefWidth="394.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="194.0" minHeight="10.0" prefHeight="49.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="317.0" minHeight="10.0" prefHeight="265.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="194.0" minHeight="10.0" prefHeight="42.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="261.0" minHeight="10.0" prefHeight="261.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
<Button fx:id="create" mnemonicParsing="false" onAction="#handleCreateActivity" prefWidth="64.0" text="Create" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="345.0" AnchorPane.rightAnchor="91.0" />
<Button fx:id="cancel" mnemonicParsing="false" onAction="#handleCancel" prefHeight="20.9998779296875" prefWidth="63.9998779296875" text="Cancel" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="116.0" AnchorPane.rightAnchor="320.0" />
<Button fx:id="modify" layoutX="345.0" layoutY="655.0" mnemonicParsing="false" onAction="#handleModify" prefWidth="63.9998779296875" text="Modify" visible="false" />
</children>
</AnchorPane>
Just use a DatePicker tag to add a DatePicker in your fxml
A sample example where I have added a DatePicker to the provided FXML is:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.collections.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" prefHeight="705.9998779296875" prefWidth="499.9998779296875" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<GridPane prefHeight="615.9998779296875" prefWidth="499.9998779296875" AnchorPane.bottomAnchor="90.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label prefHeight="24.0" prefWidth="53.0" text="Name : " GridPane.columnIndex="0" GridPane.halignment="CENTER" GridPane.rowIndex="0" GridPane.valignment="CENTER" />
<Label text="Description :" translateY="30.0" GridPane.columnIndex="0" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="TOP" />
<TextField fx:id="name" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="0" />
<TextArea fx:id="desc" prefWidth="200.0" wrapText="true" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label prefHeight="24.0" prefWidth="87.0" text="DatePicker : " GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER" />
<DatePicker fx:id="datepicker" GridPane.columnIndex="1" GridPane.rowIndex="2" />
</children>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="177.0" minWidth="10.0" prefWidth="76.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="394.0" minWidth="10.0" prefWidth="394.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="194.0" minHeight="10.0" prefHeight="49.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="317.0" minHeight="10.0" prefHeight="265.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="194.0" minHeight="10.0" prefHeight="42.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="261.0" minHeight="10.0" prefHeight="261.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
<Button fx:id="create" mnemonicParsing="false" onAction="#handleCreateActivity" prefWidth="64.0" text="Create" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="345.0" AnchorPane.rightAnchor="91.0" />
<Button fx:id="cancel" mnemonicParsing="false" onAction="#handleCancel" prefHeight="20.9998779296875" prefWidth="63.9998779296875" text="Cancel" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="116.0" AnchorPane.rightAnchor="320.0" />
<Button fx:id="modify" layoutX="345.0" layoutY="655.0" mnemonicParsing="false" onAction="#handleModify" prefWidth="63.9998779296875" text="Modify" visible="false" />
</children>
</AnchorPane>
<DatePicker xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" />
But if you work with FXML you should use the Scene Builder, which is a WYSIWYG editor.

Resources