我想能够添加鼠标事件到我的锚窗格,但我似乎无法使它工作。
room = new AnchorPane();
room.setId("AnchorPane");
room.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent e) {
// TODO Auto-generated method stub
}
});
谁能告诉我出了什么问题?
我使用以下代码修复了问题:
room.addEventHandler(MouseEvent.MOUSE_PRESSED,
new EventHandler<MouseEvent>()
public void handle(MouseEvent e) {
// TODO Auto-generated method stub
}
});