Modify Sample.fxml in the last article "Create GridPane using FXML" to replace GridPane with AnchorPane.
<?xml version="1.0" encoding="UTF-8"?> <?import java.lang.*?> <?import javafx.scene.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.text.*?> <?import javafx.scene.textfield.*?> <AnchorPane fx:controller="javafxml.Sample" xmlns:fx="http://javafx.com/fxml" prefHeight="200" prefWidth="400" > <Text text="java-Buddy" AnchorPane.topAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"/> <Label text="Who are you?" AnchorPane.topAnchor="25.0" AnchorPane.leftAnchor="0.0"/> <TextField id="textfield" fx:id="textfield" AnchorPane.topAnchor="25.0" AnchorPane.rightAnchor="0.0"/> <Button id="button" text="Click Me!" onAction="#handleButtonAction" fx:id="button" AnchorPane.topAnchor="50.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"/> <Label id="label" fx:id="label" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"/> </AnchorPane>
No comments:
Post a Comment