Example usage for javafx.scene.text Text textProperty

List of usage examples for javafx.scene.text Text textProperty

Introduction

In this page you can find the example usage for javafx.scene.text Text textProperty.

Prototype

public final StringProperty textProperty() 

Source Link

Usage

From source file:Main.java

License:asdf

@Override
public void start(Stage primaryStage) {
    User user = new User();
    Group root = new Group();
    Scene scene = new Scene(root, 320, 100);
    primaryStage.setScene(scene);/*w  w  w .j  a v  a  2  s  .  com*/

    Text userName = new Text();
    userName.textProperty().bind(user.userNameProperty());

    PasswordField passwordField = new PasswordField();
    passwordField.setPromptText("Password");
    user.passwordProperty().bind(passwordField.textProperty());

    // user hits the enter key
    passwordField.setOnAction(actionEvent -> {
        if (accessGranted.get()) {
            System.out.println("granted access:" + user.getUserName());
            System.out.println("password:" + user.getPassword());
            Platform.exit();
        } else {
            primaryStage.setTitle("no access");
        }
    });

    passwordField.textProperty().addListener((obs, ov, nv) -> {
        boolean granted = passwordField.getText().equals(MY_PASS);
        accessGranted.set(granted);
        if (granted) {
            primaryStage.setTitle("");
        }
    });
    VBox formLayout = new VBox(4);
    formLayout.getChildren().addAll(userName, passwordField);
    formLayout.setLayoutX(12);
    formLayout.setLayoutY(12);

    root.getChildren().addAll(formLayout);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Keyboard");
    Group root = new Group();
    Scene scene = new Scene(root, 530, 300, Color.WHITE);

    final StringProperty statusProperty = new SimpleStringProperty();

    InnerShadow iShadow = InnerShadowBuilder.create().offsetX(3.5f).offsetY(3.5f).build();
    final Text status = TextBuilder.create().effect(iShadow).x(100).y(50).fill(Color.LIME)
            .font(Font.font(null, FontWeight.BOLD, 35)).translateY(50).build();
    status.textProperty().bind(statusProperty);
    statusProperty.set("Line\nLine2\nLine");
    root.getChildren().add(status);/*w  w w.  j a va  2 s .  co  m*/

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:User.java

private HBox drawRow1() {
    Text userNameField = new Text();
    userNameField.setFont(Font.font("SanSerif", FontWeight.BOLD, 30));
    userNameField.setFill(foregroundColor);
    userNameField.setSmooth(true);/* ww  w. jav  a  2  s  .co m*/

    // bind the field to the user.username
    userNameField.textProperty().bind(user.userNameProperty());

    HBox userNameCell = new HBox();
    userNameCell.prefWidthProperty().bind(primaryStage.widthProperty().subtract(45));
    userNameCell.getChildren().add(userNameField);

    HBox row1 = new HBox();
    row1.getChildren().addAll(userNameCell);

    return row1;
}

From source file:de.pixida.logtest.designer.testrun.TestRunEditor.java

public TitledPane createPanelForLaunchingTests() {
    final Button startBtn = new Button("Run Test");
    startBtn.disableProperty().bind(this.testRunService.runningProperty());
    final double startButtonPadding = 8d;
    startBtn.setPadding(new Insets(startButtonPadding));
    startBtn.setGraphic(Icons.getIconGraphics("control_play_blue"));
    HBox.setHgrow(startBtn, Priority.ALWAYS);
    startBtn.setMaxWidth(Double.MAX_VALUE);
    startBtn.setOnAction(event -> {/*from w ww  .j  a  v  a2s  .c  o m*/
        final Job job = this.createJobFromConfig();
        this.testRunService.setJob(job);
        this.testRunService.start();
    });
    final HBox startLine = new HBox();
    startLine.getChildren().add(startBtn);
    final VBox runLines = new VBox();
    final double linesSpacing = 10d;
    runLines.setSpacing(linesSpacing);
    final TextFlow resultBar = new TextFlow();
    resultBar.backgroundProperty().bind(this.resultBarBackgroundProperty);
    this.resultBarBackgroundProperty.set(RESULT_BAR_BACKGROUND_IDLE);
    resultBar.setStyle("-fx-border-color: black; -fx-border-width:1");
    final Text resultBarText = new Text();
    resultBarText.textProperty().bind(this.resultBarTextProperty);
    this.resultBarTextProperty.set("Idle");
    resultBar.getChildren().add(resultBarText);
    resultBar.setTextAlignment(TextAlignment.CENTER);
    final double resultBarPadding = 2d;
    resultBar.setPadding(new Insets(resultBarPadding));
    final int logOutputLinesSize = 25;
    this.resultLogOutputText.setPrefRowCount(logOutputLinesSize);
    this.resultLogOutputText.setEditable(false);
    this.resultLogOutputText.setStyle("-fx-font-family: monospace");
    HBox.setHgrow(this.resultLogOutputText, Priority.ALWAYS);
    runLines.getChildren().addAll(startLine, new Text("Recent results:"), resultBar, this.resultLogOutputText);
    final TitledPane runPane = new TitledPane("Run", runLines);
    runPane.setGraphic(Icons.getIconGraphics("lightning_go"));
    runPane.setCollapsible(false);
    return runPane;
}