Write a javaFX program . . . (rest of question on picture) Second picture if for what BounceBallControl.java looks like formatted. **BounceBallControl.java here** package chapter15; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.input.KeyCode; import javafx.scene.input.MouseEvent; public class BounceBallControl extends Application {
Write a javaFX program . . . (rest of question on picture)
Second picture if for what BounceBallControl.java looks like formatted.
**BounceBallControl.java here**
package chapter15;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.MouseEvent;
public class BounceBallControl extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
BallPane ballPane = new BallPane(); // Create a ball pane
// Pause and resume animation
// ballPane.setOnMousePressed(e -> ballPane.pause());
EventHandler<MouseEvent> handle1 = new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
ballPane.pause();
}};
ballPane.setOnMousePressed(handle1);
ballPane.setOnMouseReleased(e ->{
ballPane.play();
System.out.println("mouse released");
});
// Increase and decrease animation
ballPane.setOnKeyPressed(e -> {
if (e.getCode() == KeyCode.UP) {
ballPane.increaseSpeed();
}
else if (e.getCode() == KeyCode.DOWN) {
ballPane.decreaseSpeed();
}
});
// Create a scene and place it in the stage
Scene scene = new Scene(ballPane, 400, 300);
primaryStage.setTitle("BounceBallControl"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
// Must request focus after the primary stage is displayed
ballPane.requestFocus();
}
/**
* The main method is only needed for the IDE with limited
* JavaFX support. Not needed for running from the command line.
*/
public static void main(String[] args) {
launch(args);
}
}
}

![package chapter15;
import javafx.application.Application;
import javafx.event.ActionEvent;
5
import javafx.event.EventHandler;
6
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.input. Keycode;
9
import javafx.scene.input.MouseEvent;
10
public class BounceBallControl extends Application {
@override // Override the start method in the Application class
public void start(Stage primaryStage) {
BallPane bal1Pane = new BallPane(); // Create a ball pane
11
12
13
14
15
// Pause and resume animation
// ballPane.setOnMousePressed(e -> ballPane.pause());
16
17
18
19
EventHandlercMouseEvent> handlel = new EventHandler<MouseEvent> () {
20
21
@Override
22
public void handle (MouseEvent arge) {
23
ballPane.pause();
24
}};
25
ballPane.set0nMousePressed(handle1);
26
27
28
ballPane.setOnMouseReleased (e ->{
29
ballPane.play();
30
System.out.printin("mouse released");
31
});
32
// Increase and decrease animation
ballPane.setonkeyPressed (e -> {
if (e.getCode() == KeyCode.UP) {
ballPane.increaseSpeed ();
33
34
35
36
37
else if (e.getCode() KeyCode. DOWN) {
ballPane.decreaseSpeed ();
38
39
40
41
});
42
43
// Create a scene and place it in the stage
44
Scene scene = new Scene(ballPane, 400, 300);
primarystage. setTitle("BounceBallControl1"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
45
46
47
primarystage. show(); // Display the stage
48
// Must request focus after the primary stage is displayed
ballPane.requestFocus ();
49
50
51
}
52
53
/**
* The main method is only needed for the IDE with limited
* JavaFX support. Not needed for running from the command line.
54
55
56
*/
57
public static void main(String[] args) {
58
launch(args);
59
}
60
}](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F376a0849-0c16-44f0-be40-275abe9469bd%2F1285edba-23e4-4968-a610-b3e0ecf396d5%2Fllapqoi_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 3 steps









