0

in my app I have a HTMLEditor and I want to highlight White Spaces to show the user where my editor inserted white spaces. In Swing this was easy but I can't find out how to do it with JavaFX. I know that there is already a question about styled text in general Styled text in JavaFX? but here I am interested in white spaces specifically. Any suggestion?

Many thanks

Community
  • 1
  • 1
Guido
  • 926
  • 2
  • 10
  • 19

1 Answers1

0

Because of the suggestion from Andrew Thompson, I found the solution. This solution uses the html 'pre' tag.

<!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>

Please also have a look at HTML <pre> tag causes linebreaks

Community
  • 1
  • 1
Guido
  • 926
  • 2
  • 10
  • 19