Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

onMouseClicked event handler not working

868267Jun 11 2011 — edited Jun 14 2011
I'm currently playing with Netbeans 7.0 and JavaFX 2.0-beta (Java 1.6.0_26, OS Windows XP) and noticed, that the onMouseClicked event handler doesn't seem to work properly.

I added one to the scene but it got triggered only very sporadical, when I hit the mouse button several times really fast. The onMousePressed and onMouseReleased handlers on the other side work as expected.

I also tried adding a click event handler to other nodes like a Rectangle or a Pane but it's always the same behaviour.

Is this a (known) bug or limitation of the beta release or am I missing something here?

Here is a a short example:
public void start(Stage primaryStage) {
        primaryStage.setTitle("JavaFX");
        
        final BorderPane root = new BorderPane();
        final Scene scene = new Scene(root, 800, 600, Color.BLACK);
        scene.setOnMouseClicked(new EventHandler<MouseEvent>() {
            public void handle(MouseEvent event) {
                System.out.println("click");
            }
        });
        primaryStage.setScene(scene);
        primaryStage.centerOnScreen();
        primaryStage.setVisible(true);
}
Regards,

Kai

Edited by: 865264 on 11.06.2011 13:29 (thanks for the tip, Darryl)
This post has been answered by Evak-Oracle on Jun 14 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 12 2011
Added on Jun 11 2011
2 comments
1,077 views