Question
Customize the program from Chapter 15. Make sure you include the changes you had made to the program in your Program Purpose and Customization. import
Customize the program from Chapter 15. Make sure you include the changes you had made to the program in your Program Purpose and Customization.
import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.text.Text; import javafx.stage.Stage;
public class AnonymousHandlerDemo extends Application { @Override // Override the start method in the Application class public void start(Stage primaryStage) { Text text = new Text(40, 40, "Programming is fun"); Pane pane = new Pane(text); // Hold four buttons in an HBox Button btUp = new Button("Up"); Button btDown = new Button("Down"); Button btLeft = new Button("Left"); Button btRight = new Button("Right"); HBox hBox = new HBox(btUp, btDown, btLeft, btRight); hBox.setSpacing(10); hBox.setAlignment(Pos.CENTER); BorderPane borderPane = new BorderPane(pane); borderPane.setBottom(hBox); // Create and register the handler btUp.setOnAction(new EventHandler
btDown.setOnAction(new EventHandler
// Create a scene and place it in the stage Scene scene = new Scene(borderPane, 400, 350); primaryStage.setTitle("AnonymousHandlerDemo"); // Set title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage } /** * 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); } }
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