Programmatically unfocus TextField?

In my opinion, I only have one editable content: Text in TextField. The problem is that as the user never gets rid of the focus (because there is nothing more to focus on) as soon as the TextField is focused. I want to remove focus from a TextField when the user presses Enter. I know how to react to pressing the Enter key, but I don't know how to focus the control / TextField programmatically?

Thanks for any hint!

+4
source share
2 answers

I admit that I crossed myself, but I got an answer there that I want to share here:

Call requestFocus() for the parent, for example. in my case an HBox containing a TextField.

Full example https://forums.oracle.com/forums/thread.jspa?messageID=10852574

+8
source

Yes, sorry, but I edited and added the correct link if for some reason it doesnโ€™t show here: http://docs.oracle.com/javafx/2/api/javafx/scene/Node.html#setFocused(boolean)

0
source

All Articles