gpt4 book ai didi

css - 文本对齐对齐但向右

转载 作者:行者123 更新时间:2023-11-28 09:55:56 25 4
gpt4 key购买 nike

我们想让文本对齐拉伸(stretch)线条并使宽度相等,但从 InlineCssTextArea(来自 RichTextFX)的右侧开始。

我用过:

-fx-text-alignment:justify;

The result

Required

还有我需要什么才能让它工作?

最佳答案

这是一个可运行的示例,其中包含您想要的结果输出我通过将节点方向设置为从右到左

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.NodeOrientation;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import org.fxmisc.richtext.InlineCssTextArea;

public class Main extends Application {

@Override
public void start(Stage stage) {
InlineCssTextArea inlineCssTextArea = new InlineCssTextArea();
inlineCssTextArea.setMinHeight(200);
inlineCssTextArea.setPadding(new Insets(20, 20, 20,20));
inlineCssTextArea.setWrapText(true);
inlineCssTextArea.appendText("Lorem ipsum dolor sit amet, veritus volumus sapientem ad pri, his delicata" +
" splendide eu, nostrum intellegat liberavisse ei duo. Quaeque bonorum ex pri, et usu dicant oportere" +
" qualisque. Suscipit deseruisse philosophia te mel. Pro ad assum intellegat, at vel sumo percipitur," +
" nam principes dissentias persequeris eu. Oratio singulis gloriatur eum te," +
" elitr soluta molestie nec an.");

//The next line is what you need
inlineCssTextArea.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);


VBox vBox = new VBox(inlineCssTextArea);
vBox.setAlignment(Pos.CENTER);

Scene scene = new Scene(vBox);

stage.setWidth(500);
stage.setScene(scene);
stage.show();
}

public static void main(String[] args) { launch(args); }
}

关于css - 文本对齐对齐但向右,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50319820/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com