如何修复在 javafx 中使用 LineNumberFactory 函数时不显示的数字?

问题描述 投票:0回答:1

我尝试使用

LineNumberFactory
函数添加行号,但它们仅显示为灰色矩形它看起来如何

我尝试在我的css文件中添加

.lineno
.fold-indicator
类(像这样)

.fold-indicator{
-fx-background-color:#292929;
}
.fold-indicator .lineno{
-fx-fill:#4a4a4a;
}

并更改背景和文本颜色,但它没有做任何事情。这就是我的 java 代码的样子:

    private Node createTextAreaBox() {
 mainCodeArea = new CodeArea();
        mainCodeArea.setId("mainCodeArea");
        mainCodeArea.setParagraphGraphicFactory(LineNumberFactory.get(mainCodeArea));
 if(initialText){
            mainCodeArea.replaceText(textAreaText);
        }
        else{
            mainCodeArea.replaceText("");
        }
}

关于可能出什么问题有什么想法吗?

java javafx richtextfx
1个回答
0
投票

首先在代码区提供css类名

<CustomCodeArea fx:id="codeJsonResponse"
                styleClass="code-area"
                minHeight="-Infinity"
                minWidth="-Infinity"
                AnchorPane.bottomAnchor="0.0"
                AnchorPane.leftAnchor="0.0"
                AnchorPane.rightAnchor="0.0"
                AnchorPane.topAnchor="0.0"
                VBox.vgrow="ALWAYS"/>

之后定义CSS,如下所示

.code-area .lineno {
    -fx-background-color: blue;
    -fx-text-fill: white;
}

我正在测试逻辑这里。它在我当地有效。 local

参考:https://github.com/FXMisc/RichTextFX/issues/1124

© www.soinside.com 2019 - 2024. All rights reserved.