I am building an app in javaFx but the problem is my app doesn't resize, if I open the app the small window is which is fine but when I maximize the window the app content(table) doesn't resize accordingly. here is my fxml file.
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.String?>
<?import javafx.collections.FXCollections?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.Buildsapp.Main.BuildsController">
<children>
<ComboBox fx:id="versionCombo" layoutX="6.0" layoutY="14.0" prefWidth="150.0" promptText="7.0 Win">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="Win" />
<String fx:value="Mac" />
</FXCollections>
</items>
<value>
<String fx:value="Win" />
</value>
</ComboBox>
<TableView fx:id="tableView" layoutX="6.0" layoutY="52.0">
<columns>
<TableColumn fx:id="builds" prefWidth="482.0" text="Builds" />
<TableColumn fx:id="date" minWidth="0.0" prefWidth="124.0" text="Date" />
<TableColumn fx:id="release" prefWidth="167.0" text="Release" />
</columns>
</TableView>
<Button fx:id="downloadButton" layoutX="328.0" layoutY="14.0" mnemonicParsing="false" text="Download" />
<Button fx:id="installButton" layoutX="458.0" layoutY="14.0" mnemonicParsing="false" text="Install" />
<ComboBox fx:id="locCombo" layoutX="636.0" layoutY="14.0" prefWidth="150.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="CJ" />
<String fx:value="MN" />
</FXCollections>
</items>
<value>
<String fx:value="CJ" />
</value>
</ComboBox>
<ComboBox fx:id="versionNo" layoutX="177.0" layoutY="14.0" prefHeight="31.0" prefWidth="122.0" promptText="7.0" />
</children>
</AnchorPane>
here is code for binding.
public void initRootLayout() {
try {
// Load root layout from fxml file.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("BuildsView.fxml"));
rootLayout = (AnchorPane) loader.load();
Scene scene = new Scene(rootLayout);
rootLayout.sceneProperty().addListener(new ChangeListener<Scene>() {
@Override
public void changed(ObservableValue<? extends Scene> observable,
Scene oldValue, Scene newValue) {
rootLayout.prefWidthProperty().bind(newValue.widthProperty());
rootLayout.prefHeightProperty().bind(newValue.heightProperty());
}
});
primaryStage.setScene(scene);
primaryStage.show();
} catch (IOException e) {
e.printStackTrace();
}
}