[英]Mouse pressed event on Anchorpane javafx
I am trying to make a mouse event work in my javaFx. 我正在尝试使鼠标事件在我的javaFx中工作。 i Want to be able to add a mouse event to my anchorpane but i cant seem to make it work. 我希望能够将鼠标事件添加到我的锚定窗格中,但我似乎无法使其正常工作。
room = new AnchorPane();
room.setId("AnchorPane");
room.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent e) {
// TODO Auto-generated method stub
}
});
Can anyone tell me what the problem is? 谁能告诉我问题出在哪里?
I fixed the problem with the following code: 我用以下代码解决了这个问题:
room.addEventHandler(MouseEvent.MOUSE_PRESSED,
new EventHandler<MouseEvent>()
public void handle(MouseEvent e) {
// TODO Auto-generated method stub
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.