Binding Stage x, y, width, height to Text control : Text « JavaFX « Java

Binding Stage x, y, width, height to Text control


import javafx.application.Application;
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) {
  public void start(Stage stage) {
    final Stage stageRef = stage;
    Group rootGroup;
    Scene scene  = SceneBuilder.create()
        rootGroup = GroupBuilder.create()
                textStageX = TextBuilder.create()
                textStageY = TextBuilder.create()
                textStageW = TextBuilder.create()
                textStageH = TextBuilder.create()
                textStageF = TextBuilder.create()

    textStageX.textProperty().bind(new SimpleStringProperty("x: ")
    textStageY.textProperty().bind(new SimpleStringProperty("y: ")
    textStageW.textProperty().bind(new SimpleStringProperty("width: ")
    textStageH.textProperty().bind(new SimpleStringProperty("height: ")
    textStageF.textProperty().bind(new SimpleStringProperty("focused: ")



Related examples in the same category

1.Create Static Text control and set color
2.Rotate a Text
3.Text with DropShadow
4.Text with CHOCOLATE color and Font.SERIF
5.Line breaking for Text
6.Reflection effect on text
7.Set fill and font for Text
8.Text wrapping width
9.Set Text Font
10.Text class defines a node that displays a text
11.Reflected Text
12.Text Effect show off
13.Paragraphs are separated by '\n' and the text is wrapped on paragraph boundaries.