在我的应用程序中,我有一个 HTMLEditor,我想突出显示空白以向用户显示我的编辑器在哪里插入了空白。在 Swing 中这很容易,但我不知道如何使用 JavaFX 来实现。我知道JavaFX中的一般样式文本已经存在一个关于样式文本的问题?但在这里我特别对空白感兴趣。有什么建议吗?
非常感谢
在我的应用程序中,我有一个 HTMLEditor,我想突出显示空白以向用户显示我的编辑器在哪里插入了空白。在 Swing 中这很容易,但我不知道如何使用 JavaFX 来实现。我知道JavaFX中的一般样式文本已经存在一个关于样式文本的问题?但在这里我特别对空白感兴趣。有什么建议吗?
非常感谢
由于 Andrew Thompson 的建议,我找到了解决方案。此解决方案使用 html 'pre' 标签。
<!DOCTYPE html>
<html>
<style type="text/css">
pre {
display: inline;
color:red;
background:green;
font-family: monospace;
white-space: pre;
margin: 0em 0;
}
</style>
<body>
Hello everybody <pre> Text in a pre element
is displayed in a fixed-width font, and it preserves
both spaces and line breaks </pre>
</body>
</html>