Using binding for visual help

While studying JavaFX classes, you can conveniently check how properties work using binding to a slider or checkbox—add them to your program, bind to the property you are interested in, and observe how different values of this property affect the corresponding node.

For example, let's look at this circle and bind a few sliders to its stroke and radius:

// chapter3/basics/CirclePropertiesDemo.javapublic void start(Stage primaryStage) {        Circle circle = new Circle(150, 150, 40, Color.ANTIQUEWHITE);        circle.setStroke(Color.BLACK);        Slider sliderRadius = new Slider(0, 100, 40);        sliderRadius.relocate(80, 20);        sliderRadius.setShowTickLabels(true);        sliderRadius.setMajorTickUnit(20);                circle.radiusProperty() .bind(sliderRadius.valueProperty()); ...

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.