Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA PROGRAM Create a new version of the EllipseSliders program from Chapter 10 that uses change listeners instead of property binding to achieve the same
JAVA PROGRAM
Create a new version of the EllipseSliders program from Chapter 10 that uses change listeners instead of property binding to achieve the same functionality.
import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Orientation; import javafx.scene.Scene; import javafx.scene.control.Slider; import javafx.scene.layout.BorderPane; import javafx.scene.paint.Color; import javafx.scene.shape.Ellipse; import javafx.stage.Stage; //************************************************************************ // EllipseSliders.java Author: Lewis/Loftus // // Demonstrates the use of slider controls and property binding. //************************************************************************ public class EllipseSliders extends Application { private Ellipse ellipse; private Slider xSlider, ySlider; //-------------------------------------------------------------------- // Displays an ellipse with sliders that control the width and // height of the ellipse. //-------------------------------------------------------------------- public void start(Stage primaryStage) { ellipse = new Ellipse(250, 150, 150, 75); ellipse.setFill(Color.SALMON); xSlider = new Slider(0, 200, 150); xSlider.setShowTickMarks(true); xSlider.setPadding(new Insets(0, 20, 20, 80)); ellipse.radiusXProperty().bind(xSlider.valueProperty()); ySlider = new Slider(0, 100, 75); ySlider.setOrientation(Orientation.VERTICAL); ySlider.setShowTickMarks(true); ySlider.setPadding(new Insets(20, 0, 0, 30)); ellipse.radiusYProperty().bind(ySlider.valueProperty()); BorderPane pane = new BorderPane(); pane.setLeft(ySlider); pane.setBottom(xSlider); pane.setCenter(ellipse); pane.setStyle("-fx-background-color: grey"); Scene scene = new Scene(pane, 500, 300); primaryStage.setTitle("Ellipse Sliders"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started