Issue
I don't know what is the grey area and how to extend my Anchorpane
to all over the screen
Image
the not unmaximized view is this rel="nofollow noreferrer">image2
My Fxml is a bit messy with alot of an Anchorpanes but it was out of my hand.
<?xml version="1.0" encoding="UTF-8"?>
<!-- <?import com.gluonhq.charm.glisten.control.TextField?> -->
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.DatePicker?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<VBox alignment="CENTER" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.maxxplusapi.controller.ActvityPlannerController">
<children>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity">
<children>
<AnchorPane style="-fx-background-color: white;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<TextField fx:id="beginTime" layoutX="256.0" layoutY="189.0" prefHeight="26.0" prefWidth="172.0" promptText="Beginnzeit" style="-fx-border-color: black;" />
<TextField fx:id="endTime" layoutX="472.0" layoutY="189.0" prefHeight="26.0" prefWidth="172.0" promptText="Endzeit" style="-fx-border-color: black;" />
<TextField fx:id="reminderDesc" layoutX="255.0" layoutY="104.0" prefHeight="26.0" prefWidth="388.0" promptText="Erinnerungsnachricht" style="-fx-border-color: black;" />
<TextField fx:id="txtRemarks" layoutX="255.0" layoutY="145.0" prefHeight="26.0" prefWidth="388.0" promptText="Remarks" style="-fx-border-color: black;" />
<Button fx:id="saveButton" layoutX="309.0" layoutY="357.0" mnemonicParsing="false" onMouseClicked="#addData" prefHeight="25.0" prefWidth="92.0" style="-fx-border-color: black;" text="Speichern" />
<AnchorPane>
<children>
<AnchorPane layoutY="-8.0" prefHeight="43.0" prefWidth="925.0" style="-fx-background-color: #2e4b75;"/>
</children>
</AnchorPane>
<Label layoutX="446.0" layoutY="243.0" text="Intervall" />
<Label layoutX="252.0" layoutY="280.0" text="Projekt Bereich" />
<ComboBox fx:id="cycleComboBox" layoutX="494.0" layoutY="238.0" prefWidth="150.0" style="-fx-border-color: black;" />
<ComboBox fx:id="projectComboBox" layoutX="252.0" layoutY="304.0" prefHeight="27.0" prefWidth="388.0" style="-fx-border-color: black;" />
<Button fx:id="updateButton" layoutX="309.0" layoutY="357.0" mnemonicParsing="false" onMouseClicked="#Edit" prefHeight="25.0" prefWidth="92.0" text="Update" />
<Text layoutX="225.0" layoutY="85.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Aktivitätsplaner " textAlignment="CENTER" wrappingWidth="452.7265625">
<font>
<Font name="System Bold" size="36.0" />
</font>
</Text>
<Button contentDisplay="CENTER" layoutX="404.0" layoutY="357.0" mnemonicParsing="false" onMouseClicked="#DeleteData" prefHeight="25.0" prefWidth="92.0" text="Delete" />
<TableView fx:id="tableViewBooking" layoutX="104.0" layoutY="403.0" onMouseClicked="#getSelected" prefHeight="238.0" prefWidth="694.0">
<columns>
<TableColumn fx:id="tableID" editable="false" prefWidth="76.800048828125" text="id" />
<TableColumn fx:id="tableColName" editable="false" prefWidth="104.79997253417969" text="Erinnerung" />
<TableColumn fx:id="tableColRemarks" editable="false" prefWidth="104.79997253417969" text="Remarks" />
<TableColumn fx:id="tableColProject" editable="false" prefWidth="104.79997253417969" text="Projekt" />
<TableColumn fx:id="tableColDate" editable="false" prefWidth="83.20001220703125" text="Begin Datum" />
<TableColumn fx:id="tableColHours" editable="false" prefWidth="66.39996337890625" text="Stunde" />
<TableColumn fx:id="tableColType" editable="false" prefWidth="71.20001220703125" text="Intervall" />
<TableColumn fx:id="tableColSTime" editable="false" prefWidth="76.800048828125" text="Begin Zeit" />
<TableColumn fx:id="tableColETime" editable="false" prefWidth="76.800048828125" text="End Zeit" />
<!--<TableColumn fx:id="tableColProj" prefWidth="75.0" text="Projekt" /> -->
</columns>
</TableView>
<DatePicker fx:id="beginDate" layoutX="253.0" layoutY="239.0" prefHeight="26.0" prefWidth="172.0" promptText="Begindatum" />
<DatePicker fx:id="endDate" layoutX="441.0" layoutY="239.0" prefHeight="26.0" prefWidth="172.0" promptText="Enddatum" visible="false" />
<Button layoutX="500.0" layoutY="357.0" mnemonicParsing="false" onMouseClicked="#clearFields" prefHeight="25.0" prefWidth="92.0" text="Clear" />
</children>
</AnchorPane>
</children>
</AnchorPane>
</children>
</VBox>
I tried using AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" on my child AnchorPane but didn't work
Solution
I created a version of your FXML
file. Try to incorporate the ideas from this answer into your Layout.
<?xml version="1.0" encoding="UTF-8"?>
<!-- <?import com.gluonhq.charm.glisten.control.TextField?> -->
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<VBox alignment="CENTER" prefHeight="720.0" prefWidth="1080.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.maxxplusapi.controller.ActvityPlannerController">
<children>
<StackPane maxHeight="55.0" minHeight="43.0" style="-fx-background-color: #2e4b75;" />
<VBox prefHeight="200.0" prefWidth="100.0" VBox.vgrow="ALWAYS">
<children>
<Label alignment="CENTER" maxWidth="1.7976931348623157E308" text="Aktivitätsplaner ">
<font>
<Font size="36.0" />
</font>
<VBox.margin>
<Insets top="10.0" />
</VBox.margin>
</Label>
<TextField fx:id="reminderDesc" promptText="Erinnerungsnachricht" style="-fx-border-color: black;">
<VBox.margin>
<Insets left="300.0" right="300.0" top="15.0" />
</VBox.margin>
</TextField>
<TextField fx:id="txtRemarks" prefHeight="26.0" prefWidth="388.0" promptText="Remarks" style="-fx-border-color: black;">
<VBox.margin>
<Insets left="300.0" right="300.0" top="15.0" />
</VBox.margin>
</TextField>
<HBox>
<children>
<TextField fx:id="beginTime" prefHeight="26.0" prefWidth="172.0" promptText="Beginnzeit" style="-fx-border-color: black;" />
<Label alignment="CENTER_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" text="Intervall" HBox.hgrow="ALWAYS">
<HBox.margin>
<Insets right="5.0" />
</HBox.margin>
</Label>
<ComboBox fx:id="cycleComboBox" prefWidth="150.0" style="-fx-border-color: black;" />
</children>
<VBox.margin>
<Insets left="300.0" right="300.0" top="15.0" />
</VBox.margin>
</HBox>
<Label maxWidth="1.7976931348623157E308" text="Projekt Bereich">
<VBox.margin>
<Insets left="300.0" right="300.0" top="15.0" />
</VBox.margin>
</Label>
<ComboBox fx:id="projectComboBox" maxWidth="1.7976931348623157E308" style="-fx-border-color: black;">
<VBox.margin>
<Insets left="300.0" right="300.0" top="15.0" />
</VBox.margin>
</ComboBox>
<HBox alignment="CENTER" maxWidth="1.7976931348623157E308" spacing="5.0">
<children>
<Button fx:id="updateButton" mnemonicParsing="false" onMouseClicked="#Edit" prefHeight="25.0" prefWidth="92.0" text="Update" />
<Button contentDisplay="CENTER" mnemonicParsing="false" onMouseClicked="#DeleteData" prefHeight="25.0" prefWidth="92.0" text="Delete" />
<Button mnemonicParsing="false" onMouseClicked="#clearFields" prefHeight="25.0" prefWidth="92.0" text="Clear" />
</children>
<padding>
<Insets left="300.0" right="300.0" top="15.0" />
</padding>
</HBox>
<TableView fx:id="tableViewBooking" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" onMouseClicked="#getSelected" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="tableID" editable="false" prefWidth="76.800048828125" text="id" />
<TableColumn fx:id="tableColName" editable="false" prefWidth="104.79997253417969" text="Erinnerung" />
<TableColumn fx:id="tableColRemarks" editable="false" prefWidth="104.79997253417969" text="Remarks" />
<TableColumn fx:id="tableColProject" editable="false" prefWidth="104.79997253417969" text="Projekt" />
<TableColumn fx:id="tableColDate" editable="false" prefWidth="83.20001220703125" text="Begin Datum" />
<TableColumn fx:id="tableColHours" editable="false" prefWidth="66.39996337890625" text="Stunde" />
<TableColumn fx:id="tableColType" editable="false" prefWidth="71.20001220703125" text="Intervall" />
<TableColumn fx:id="tableColSTime" editable="false" prefWidth="76.800048828125" text="Begin Zeit" />
<TableColumn fx:id="tableColETime" editable="false" prefWidth="76.800048828125" text="End Zeit" />
</columns>
<VBox.margin>
<Insets bottom="10.0" left="150.0" right="150.0" top="25.0" />
</VBox.margin>
</TableView>
</children>
</VBox>
</children>
</VBox>
- Save this as an
FXML
file to your machine. - Open it using SceneBuilder.
- Press control+p after it opens in SceneBuilder.
- Test by minimizing and maximizing the screen.
Answered By - SedJ601
Answer Checked By - Gilberto Lyons (JavaFixing Admin)