Example usage for javafx.scene.text Text setWrappingWidth

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

Introduction

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

Prototype

public final void setWrappingWidth(double value) 

Source Link

Usage

From source file:de.micromata.mgc.javafx.FXGuiUtils.java

/**
 * Computes the required height of a text for a given font and a wrapping width. Wrapping width defines when a text
 * needs to be wrapped if its {@link Label#wrapTextProperty()} is true.
 * // w w w.  ja  va 2  s  .c  om
 * @param font font of the label.
 * @param text text to render.
 * @param wrappingWidth wrapping width.
 * @return height.
 */
public static double computeTextHeight(Font font, String text, double wrappingWidth) {
    final Text helper = new Text();
    helper.setText(text);
    helper.setFont(font);

    helper.setWrappingWidth((int) wrappingWidth);
    return helper.getLayoutBounds().getHeight();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);/*from   ww  w.ja  v  a 2  s.co  m*/
    stage.setTitle("Sample");

    Text t = new Text(10, 50, "This is a test");
    t.setWrappingWidth(200);
    t.setText("First row Second row Second row Second row Second row Second row ");
    t.setFont(new Font(20));

    root.getChildren().add(t);

    stage.show();
}

From source file:kz.aksay.polygraph.desktop.LoginPane.java

public LoginPane() {
    GridPane grid = this;

    grid.setAlignment(Pos.CENTER);//from   ww  w  .  java2 s  .c om
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    sceneTitle = new Text(" ");
    sceneTitle.setId("welcome-text");
    grid.add(sceneTitle, 0, 0, 2, 1);

    userName = new Label(":");
    grid.add(userName, 0, 1);

    userTextField = new TextField();
    grid.add(userTextField, 1, 1);

    password = new Label(":");
    grid.add(password, 0, 2);

    passwordTextBox = new PasswordField();
    grid.add(passwordTextBox, 1, 2);

    signIn = new Button("");
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(signIn);
    grid.add(hbBtn, 1, 4);

    final Text actionTarget = new Text();
    actionTarget.setId("action-target");
    actionTarget.setWrappingWidth(300);
    grid.add(actionTarget, 0, 6, 2, 1);

    signIn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            if (isSignInSuccess()) {
                onSignInSuccess.handle(e);
            } else {
                actionTarget.setText(
                        "?   .   !");
            }
        }
    });
}

From source file:UI.MainStageController.java

@FXML
/**//from w  w  w  .  j  a  v a  2s. c  om
 *
 * Shows information about the software.
 */
private void showAboutAlert() {
    Hyperlink hyperlink = new Hyperlink();
    hyperlink.setText("https://github.com/jmueller95/CORNETTO");
    Text text = new Text("Cornetto is a modern tool to visualize and calculate correlations between"
            + "samples.\nIt was created in 2017 by students of the group of Professor Huson in Tbingen.\nThe group"
            + "was supervised by Caner Bagci.\n\n" + "This project is licensed under the MIT License.\n\n"
            + "For more information go to: ");

    TextFlow textFlow = new TextFlow(text, hyperlink);

    text.setWrappingWidth(500);
    aboutAlert = new Alert(Alert.AlertType.INFORMATION);
    aboutAlert.setTitle("About " + GlobalConstants.NAME_OF_PROGRAM);
    aboutAlert.setHeaderText("What is " + GlobalConstants.NAME_OF_PROGRAM);
    aboutAlert.getDialogPane().setContent(textFlow);
    aboutAlert.show();
}