Skip to content

Unable to center paragraph. #548

@PatrickDattilio

Description

@PatrickDattilio

I have an InlineCssTextArea where I append a line of text and then attempt to center the entire paragraph. I've tried setting the setParagraphStyle and setStyle, but neither seems to work. I've attached a sample that shows the behavior, any ideas where I might be going wrong?

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import org.fxmisc.richtext.InlineCssTextArea;

public class Example extends Application {

    public static void main(String args[]){
        launch(Example.class);
    }
    @Override
    public void start(Stage primaryStage) throws Exception {

        GridPane root = new GridPane();
        Scene scene = new Scene(root, 900.0,900.0);
        InlineCssTextArea area = new InlineCssTextArea();
        root.add(area, 0, 5, 4, 1);
        primaryStage.setTitle("Example");
        primaryStage.setScene(scene);
        primaryStage.show();

        area.appendText("Test");

        area.setParagraphStyle(area.getCurrentParagraph(), "-fx-text-align: center;");
        area.setStyle(area.getCurrentParagraph(), "-fx-text-align: center;");

    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions