Is there a way to take away focus in javafx?

前端 未结 3 1695
迷失自我
迷失自我 2021-01-04 13:20

I know that your can give focus to a node in javafx by doing node.requestFocus(); but is there a way to take away focus from a node in javafx or prevent focus on an

3条回答
  •  醉梦人生
    2021-01-04 13:38

    If you have another node then you can remove focus from your node and give it to another with this.

    otherNode.requestFocus();
    

    By doing this you won't need to disable or enable your original node.

    Some nodes such as a Label won't look different when they have focus, so this can make it appear as if focus was removed.

提交回复
热议问题