4、Button

按钮

Button btn = new Button("btn");
//鼠标点击事件
btn.setOnMouseClicked(new EventHandler<MouseEvent>() {
    @Override
    public void handle(MouseEvent event) {
        System.out.println("click");
    }
});
//鼠标双击以及鼠标按钮
btn.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
    @Override
    public void handle(MouseEvent event) {
        if (event.getClickCount() == 2){
            System.out.println("click double");
            MouseButton mouseButton = event.getButton();
            // 获取鼠标按钮
            String name = mouseButton.name();
            System.out.println(name);
        }
    }
});