Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Progam Add in a: textfield passwordfield scrollbar radiobutton checkbox ButtonDemo.java import javafx.application.Application; import javafx.stage.Stage; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.image.ImageView; import javafx.scene.layout.BorderPane;

Java Progam

Add in a:

textfield

passwordfield

scrollbar

radiobutton

checkbox

ButtonDemo.java

import javafx.application.Application; import javafx.stage.Stage; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.image.ImageView; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.text.Text;

public class ButtonDemo extends Application { protected Text text = new Text(50, 50, "JavaFX Programming");

protected BorderPane getPane() { HBox paneForButtons = new HBox(20); Button btLeft = new Button("Left", new ImageView("image/left.gif")); Button btRight = new Button("Right", new ImageView("image/right.gif")); paneForButtons.getChildren().addAll(btLeft, btRight); paneForButtons.setAlignment(Pos.CENTER); paneForButtons.setStyle("-fx-border-color: green");

BorderPane pane = new BorderPane(); pane.setBottom(paneForButtons);

Pane paneForText = new Pane(); paneForText.getChildren().add(text); pane.setCenter(paneForText);

btLeft.setOnAction(e -> text.setX(text.getX() - 10)); btRight.setOnAction(e -> text.setX(text.getX() + 10));

return pane; }

@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a scene and place it in the stage Scene scene = new Scene(getPane(), 450, 200); primaryStage.setTitle("ButtonDemo"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage } }

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

Recommended Textbook for

More Books

Students also viewed these Databases questions