Sunday, May 20, 2012

Create BorderPane using FXML

javafx.scene.layout.BorderPane lays out children in top, left, right, bottom, and center positions.

By using FXML, we can change the visual view without touch the Java code.

BorderPane using FXML

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="" 
    prefHeight="200" prefWidth="320">
        <Text text="java-Buddy"/>
        <Label text="Who are you?"/>
        <TextField id="textfield" fx:id="textfield"/>
        <Button id="button"  text="Click Me!" 
            onAction="#handleButtonAction" fx:id="button"/>
        <Label id="label" fx:id="label"/>


No comments:

Post a Comment