Mouse pressed event on Anchorpane javafx


Question

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?

1
0
12/18/2012 12:32:24 AM

Accepted Answer

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

    }
});
1
12/23/2012 2:34:25 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon