I want to change the TextArea cursor, but nothing happens when I use this:
numTextArea.setCursor(Cursor.DISAPPEAR);
I want to change the TextArea cursor, but nothing happens when I use this:
numTextArea.setCursor(Cursor.DISAPPEAR);
Copyright © 2021 Jogjafile Inc.
The default skin of
TextAreaincludes a "content area", which is documented as aRegion. It's this content area that has its cursor set toCursor.TEXT(by the default user agent stylesheet). And since the mouse is hovering over the content area, not the text area directly, you see the cursor of the content area instead of the text area.The likely easiest way to change the cursor is to use CSS.
Then add the stylesheet to the scene (or the text area, or an ancestor layout). For example:
Note: The above adds the stylehseet to the scene via a data URL. This requires JavaFX 17+.
The example uses
Cursor.HANDbecauseCursor.DISAPPEARjust gave me the default cursor on Windows 10 with Java/JavaFX 20.0.1. Not sure if that's a bug.Note you can use
nullorinheritfor-fx-cursorin the CSS, and then set the text area's cursor in code (like you're currently trying to do).