Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to center paragraph. #548

Closed
PatrickDattilio opened this issue Jul 28, 2017 · 4 comments
Closed

Unable to center paragraph. #548

PatrickDattilio opened this issue Jul 28, 2017 · 4 comments

Comments

@PatrickDattilio
Copy link

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;");

    }
}
@JordanMartinez
Copy link
Contributor

JordanMartinez commented Jul 28, 2017 via email

@PatrickDattilio
Copy link
Author

Yes, the style appears to be set on both the TextExt and the ParagraphText but "Test" remains left aligned.

@JordanMartinez
Copy link
Contributor

JordanMartinez commented Jul 28, 2017 via email

@PatrickDattilio
Copy link
Author

"-fx-text-align" -> "-fx-text-alignment". Simple typo. Sorry about that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants