By using FXML, we can change the visual view without touch the Java code.
Modify Sample.fxml in the last article "Create GridPane using FXML" to replace GridPane with BorderPane.
<?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.*?> <BorderPane fx:controller="javafxml.Sample" xmlns:fx="http://javafx.com/fxml" prefHeight="200" prefWidth="320"> <top> <Text text="java-Buddy"/> </top> <left> <Label text="Who are you?"/> </left> <center> <TextField id="textfield" fx:id="textfield"/> </center> <right> <Button id="button" text="Click Me!" onAction="#handleButtonAction" fx:id="button"/> </right> <bottom> <Label id="label" fx:id="label"/> </bottom> </BorderPane>
No comments:
Post a Comment