//In Java Language please package layoutDemos; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.text.Text; import javafx.stage.Stage; public class ButtonsOnTop extends Application { @Override public void start(Stage primaryStage) { primaryStage.setTitle("Two Button VBox"); // -------------------------------------------------------------------- VBox vbox1 = new VBox(10); // the attribute sets the space between nodes vbox1.setPadding(new Insets(15, 15, 15, 15)); // sets space around the edges GridPane gridBox = new GridPane(); gridBox.setAlignment(Pos.CENTER); gridBox.setHgap(20); gridBox.setPadding(new Insets(10, 10, 15, 15)); gridBox.setStyle("-fx-background-color: CYAN"); // -------------------------------------------------------------------- Text txt1 = new Text("Text at the top of the VBox stack"); Text txt2 = new Text("Text at the bottom of the VBox stack"); Button btn1 = new Button(); Button btn2 = new Button(); // -------------------------------------------------------------------- btn1.setText("This is Button ONE"); btn1.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { System.out.println("Button One pushed"); txt1.setText("Button ONE pushed"); } }); btn2.setText("This is Button TWO"); btn2.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { System.out.println("Button Two pushed"); txt1.setText("Button TWO pushed"); } }); // -------------------------------------------------------------------- gridBox.add(btn1, 0, 0); gridBox.add(btn2, 1, 0); vbox1.getChildren().add(gridBox); vbox1.getChildren().add(txt1); vbox1.getChildren().add(txt2); Scene sc = new Scene(vbox1, 400, 250); primaryStage.setScene(sc); primaryStage.show(); } public static void main(String[] args) { Application.launch(args); } }
//In Java Language please
package layoutDemos;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class ButtonsOnTop extends Application {
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Two Button VBox");
// --------------------------------------------------------------------
VBox vbox1 = new VBox(10); // the attribute sets the space between nodes
vbox1.setPadding(new Insets(15, 15, 15, 15)); // sets space around the edges
GridPane gridBox = new GridPane();
gridBox.setAlignment(Pos.CENTER);
gridBox.setHgap(20);
gridBox.setPadding(new Insets(10, 10, 15, 15));
gridBox.setStyle("-fx-background-color: CYAN");
// --------------------------------------------------------------------
Text txt1 = new Text("Text at the top of the VBox stack");
Text txt2 = new Text("Text at the bottom of the VBox stack");
Button btn1 = new Button();
Button btn2 = new Button();
// --------------------------------------------------------------------
btn1.setText("This is Button ONE");
btn1.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Button One pushed");
txt1.setText("Button ONE pushed");
}
});
btn2.setText("This is Button TWO");
btn2.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Button Two pushed");
txt1.setText("Button TWO pushed");
}
});
// --------------------------------------------------------------------
gridBox.add(btn1, 0, 0);
gridBox.add(btn2, 1, 0);
vbox1.getChildren().add(gridBox);
vbox1.getChildren().add(txt1);
vbox1.getChildren().add(txt2);
Scene sc = new Scene(vbox1, 400, 250);
primaryStage.setScene(sc);
primaryStage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
![5.)
• Make a digital clock using ButtonsOnTop.java
• Move the buttons to the bottom of the window.
o when one button is pressed the The time will update.
• The other button shows the Date](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd78f4657-4ba2-45bb-a9f7-fec608959d4e%2F96363f58-d829-4706-b493-8c7bcc5c02f3%2Festr5kr_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)