Javafx HtmlEditor:预览颜色太小

Javafx HtmlEditor: preview color is so small

在JavaFX的HTMLEditor中:预览颜色太小了。

我想显示大一点,如下图:

我该怎么做。 谢谢

HTMLEditor 的样式是通过 CSS 自定义的。

.html-editor-foreground {
    -fx-color-rect-width: 16;
    -fx-color-rect-height: 16;
    -fx-graphic: null;
}

在这里,我们将前景颜色选择器选择的颜色指示器设置为(相对)大的矩形(为示例选择了粉红色):

示例代码

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;

public class EditorSample extends Application {
    @Override
    public void start(Stage stage) throws Exception {
        HTMLEditor editor = new HTMLEditor();

        Scene scene = new Scene(editor);
        scene.getStylesheets().add(
                this.getClass().getResource(
                        "html-editor-large-color-rect.css"
                ).toExternalForm()
        );
        stage.setScene(scene);
        stage.show();
    }

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