In: Computer Science
very urgent !!! need it asap::::::::Write Java code which will create a GUI window on screen. The window has one button: Doggy. When the user selects Doggy, “Bow Bow” should be printed on screen. Justify your syntax
package application;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class DoggyProgram extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Doggy Example!");
Label label = new Label();
Button button1 = new Button("Doggy");
button1.setOnAction(value -> {
label.setText("Bow Bow");
});
VBox hbox = new VBox(button1, label);
label.setStyle
(
"-fx-font-size:20px;"+
"-fx-padding:50px;"
);
Scene scene = new Scene(hbox, 200, 165);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}