私はコントローラクラスに非常に大きなイベントハンドリングメソッドを持っていました。私はそれぞれを別のクラスに入れましたが、今はもう呼び出されていません。私はこれを呼び出した場合、それが動作カスタムクラスを使ってjavafxでイベントハンドラを追加する
private DragDetectedHandler dragDetectedHandler = new DragDetectedHandler(stacks, nextCards, gameTable);;
node.setOnDragDetected(dragDetectedHandler);
:
node.setOnDragDetected(System.out::println);
(ただ、コードに到達したことをテストする)
およびハンドラクラスを
は、これは、現在実装されています方法です:
public class DragDetectedHandler implements EventHandler<MouseEvent> {
private Stacks stacks;
private NextCards nextCards;
private Table gameTable;
public DragDetectedHandler(Stacks stacks, NextCards nextCards, Table gameTable) {
this.stacks = stacks;
this.nextCards = nextCards;
this.gameTable = gameTable;
}
@Override
public void handle(MouseEvent mouseEvent) {
System.out.println("Handle stuff here :)");
}
}
私はおそらく何かを見落としているだろうが、同様の質問は私の答えを得るのに役立たなかった。
質問:私はイベントハンドラをどのように呼び出す必要がありますか?なぜ、次のコードはイベントハンドラを呼び出さないのですか?
node.setOnDragDetected(dragDetectedHandler);
あなたは含めるためにあなたの質問を編集してくださいすることができ...よく...疑問? –
@JoeCありがとう、私は実際に質問をするのを忘れました – Vinagy