javafx: How to bind the Enter key to a button and fire off an event when it is clicked?

前端 未结 4 1447
忘掉有多难
忘掉有多难 2020-12-16 19:06

Basically, I have a okayButton that sits in a stage and when it is clicked , it performs a list of tasks. Now I want to bind the Enter

4条回答
  •  渐次进展
    2020-12-16 19:47

    You can dynamically change the default button property of the currently focused button by using binding

    btn.defaultButtonProperty().bind(btn.focusedProperty());
    

提交回复
热议问题