javafx checkbox

public class EffectTest extends Application {
public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        stage.setTitle("Tooltip Sample");
        stage.setWidth(300);
        stage.setHeight(150);
        final CheckBox cb = new CheckBox("checkBox");
        final Tooltip tooltip = new Tooltip("$ tooltip");
        tooltip.setFont(new Font("Arial", 16));
        cb.setTooltip(tooltip);
        cb.selectedProperty().addListener(new ChangeListener<Boolean>() {
           public void changed(ObservableValue<? extends Boolean> ov,
             Boolean old_val, Boolean new_val) {
             System.out.println(cb.isSelected());
          }
        });

        ((Group) scene.getRoot()).getChildren().add(cb);

        stage.setScene(scene);
        stage.show();
    }
    
    
    
}
原文地址:https://www.cnblogs.com/rojas/p/4720461.html