Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

After reading the rest of Chapter 15 and you have practiced running the sample programs in the Chapter, analyze the BouncingBallControl program on page 619.

After reading the rest of Chapter 15 and you have practiced running the sample programs in the Chapter, analyze the BouncingBallControl program on page 619. You will see that the program uses an extend Class of pane() called BallPane on page 617. This is an example similar to the ClockPane Class that modifies a standard Application Class shown back in Chapter 14 to make a completely different application by mainly extending the Pane Class. Think about how you could add a filled-in rectangle that the user could move up and down in the BallPane. Then think about how and where you would add the check to change the ball's direction if it hits the rectangle. Could it simply be a reversal of direction or what would you have to do to simulate what really would happen if it hit the rectangle? I do not need to see a full application. This is not a programming assignment... it is meant to be a thought-provoking set of questions which forces you to really understand how the author has demonstrated how to use animations with JavaFX. Tell us what you would do to implement the above proposed modifications and answer the direction reversal question here.

image text in transcribed

image text in transcribed

javafx application. Application avafx scene ayout. Pane BalIC x: double y: double dx: double -dy: double radius double circle: Circle Time +Ball Pane +play(): void +pause(): void +increaseSpeed(): void +decrease Speed(): void +rate Property DoubleProperty +move Ball void FIGURE 15.23 BounceBa11Control contains Bal1Pane. LISTING 15.17 Ball Pane. java 1 import javafx.animation.KeyFrame; 2 import javafx.animation.Timeline; 3 import avafx.beans.property. Double Property 4 import avafx. scene ayout. Pane 5 import avafx.scene. paint. Color 6 import avafx.scene. shape. Circle 7 import javafx.util. Duration 9 public class Ba11Pane extends Pane 10 public final double radius 200 11 private double x radius, y radius 12 private double dx 1, dy- 1; 13 private Circle circle new C y, radius private Timeline animation; 16 public Ball Paneo 17 circle. setF (Color GREEN Set ball color 18 getC dren ).addocircle): Place a bal into this pane 618 Chapter 15 Event-Driven Programming and Animations 19 20 Create an animation for moving the ball 21 animation new Time ne( 22 new Key Frame (Duration. millis(50), e moveBa 11())) keep animation running 23 animatio ne INDEFINITE) 24 animation play() Start animation start anim 25 26 27 public void play() play 28 animation.play(); 29 30 31 public void pause 32 animation pause pause animation 33 34 35 public void increaseSpeedO 36 animation. setRateCanimation.getRate() 0.1); ncrease animation rate 37 38 39 public void decreaseSpeed() 40 set Rate( decrease animatio animatio 41 nimation.getRateC) 0 animation getRateC) 42 43 44 public Doub Property ratePropertyO 45 return animation.rateProperty(); 46 47 48 protected void move Ball 49 Check boundaries

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago

Question

What is the best conclusion for Xbar Chart? UCL A X B C B A LCL

Answered: 1 week ago