【发布时间】:2017-04-07 01:49:14
【问题描述】:
button.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
label.setText("Accepted");
}
});
在上面的代码中,我们定义了按下按钮时会发生什么。这一切都很好,但我想创建新的 ActionListener 然后将它添加到我的按钮。 通常在 JButton 中,我可以像这样添加 ActionListener:
button.addActionListener(someControllerClass.createButtonListener());
在上面的代码中,createButtonListener() 返回 ActionListener。
我的问题是:JButton addActionListener 的等价物是什么?
【问题讨论】:
标签: java user-interface javafx actionlistener