/* * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. */ package checkboxactioneventbug; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.Event; import javafx.event.EventHandler; import javafx.event.EventType; import javafx.geometry.Orientation; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.RadioButton; import javafx.scene.layout.FlowPane; import javafx.scene.layout.StackPane; import javafx.stage.Stage; /** * * @author Aleksandr Sakharuk */ public class CheckBoxActionEventBug extends Application { /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Hello World!"); CheckBox checkBox = new CheckBox("Check"); Button button = new Button("Button"); RadioButton radioButton = new RadioButton("Radio button"); checkBox.addEventHandler(ActionEvent.ACTION, new ActionHandler()); button.addEventHandler(ActionEvent.ACTION, new ActionHandler()); radioButton.addEventHandler(ActionEvent.ACTION, new ActionHandler()); FlowPane root = new FlowPane(Orientation.VERTICAL); root.getChildren().addAll(checkBox, button, radioButton); root.autosize(); primaryStage.setScene(new Scene(root, 250, 250)); primaryStage.show(); } private class ActionHandler implements EventHandler { @Override public void handle(ActionEvent arg0) { System.out.println("Action event handled."); } } }