I am trying to make a mouse event work in my 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
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.