Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.geometry.VPos;
import javafx.scene.Group;
import javafx.scene.GroupBuilder;
import javafx.scene.Scene;
import javafx.scene.SceneBuilder;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBoxBuilder;
import javafx.scene.paint.Color;
import javafx.scene.shape.RectangleBuilder;
import javafx.scene.text.Text;
import javafx.scene.text.TextBuilder;
import javafx.stage.Stage;

public class Main extends Application {
    StringProperty title = new SimpleStringProperty();

    Text textStageX;
    Text textStageY;
    Text textStageW;
    Text textStageH;
    Text textStageF;

    public static void main(String[] args) {
        Application.launch(args);
    }

    @Override
    public void start(Stage stage) {
        final Stage stageRef = stage;
        Group rootGroup;
        Scene scene = SceneBuilder.create().width(270).height(370)
                .root(rootGroup = GroupBuilder.create()
                        .children(VBoxBuilder.create().layoutX(30).layoutY(20).spacing(10)
                                .children(textStageX = TextBuilder.create().textOrigin(VPos.TOP).build(),
                                        textStageY = TextBuilder.create().textOrigin(VPos.TOP).build(),
                                        textStageW = TextBuilder.create().textOrigin(VPos.TOP).build(),
                                        textStageH = TextBuilder.create().textOrigin(VPos.TOP).build(),
                                        textStageF = TextBuilder.create().textOrigin(VPos.TOP).build())
                                .build())
                        .build())
                .build();

        textStageX.textProperty().bind(new SimpleStringProperty("x: ").concat(stageRef.xProperty().asString()));
        textStageY.textProperty().bind(new SimpleStringProperty("y: ").concat(stageRef.yProperty().asString()));
        textStageW.textProperty()
                .bind(new SimpleStringProperty("width: ").concat(stageRef.widthProperty().asString()));
        textStageH.textProperty()
                .bind(new SimpleStringProperty("height: ").concat(stageRef.heightProperty().asString()));
        textStageF.textProperty()
                .bind(new SimpleStringProperty("focused: ").concat(stageRef.focusedProperty().asString()));
        stage.setResizable(true);

        stage.setScene(scene);
        stage.titleProperty().bind(title);

        stage.show();
    }
}