Javafx resize components when fullscreen

The problem is because you are using AnchorPane as your root pane. Though, you can use AnchorPane for scenarios like this, I personally do not prefer it because you need to do a lot of things to get it right. There are easier ways to do and that is what I am gonna show you.

From the Javadocs :

AnchorPane allows the edges of child nodes to be anchored to an offset from the anchor pane's edges.

Solution

Use a different layout. May be a GridPane or VBox. These layouts have child alignment instead of anchors, which allow the children to be aligned to a particular position.

For re-sizing your children, you can set the HGrow / VGrow property on them.

Example

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

<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>


<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" spacing="20.0" style="-fx-background-color: DARKCYAN;" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <Label text="Easy Doctor" />
      <TextField promptText="Username" />
      <TextField promptText="Password" />
   </children>
   <padding>
      <Insets bottom="50.0" left="50.0" right="50.0" top="50.0" />
   </padding>
</VBox>

Here is a small gif on how it looks :

enter image description here