Search code examples
javafx-2

Is it possible to forbid selection in TextField?


I have a small problem: my text field keeps selecting itself, for example if I alt-tab from and to application.

For my application, text selection is not needed and will not be used - so I want to disallow this annoying behavior. Actually, just setting selection color to transparent or white will work fine.

Is there some way to do this?


Solution

  • The following css fixed the problem for me:

    -fx-highlight-fill: null;
    -fx-highlight-text-fill: null;