Answered You can buy a ready-made answer or pick a professional tutor to order an original one.

QUESTION

Use JavaFX. No Swing or Awt Enhanced the Hollywood Star Generator app Write a program that allows a user to enter a name into an input box and your program will display a star similar to the screensh

Use JavaFX. No Swing or Awt

Enhanced the Hollywood Star Generator app

Write a program that allows a user to enter a name into an input box  and your program will display a star similar to the screenshot shown  below, with a name displayed in the star. Below are the requirements of  the program (or app):

1. Add a Star shape and the following:

a. fill the color with “Aqua” and

b. set the shape stroke with “Gold” color and

c. set stroke width to 5px.

2. Add a text shape and the following:

a. set the default text to “Your-Name” and

b. set the text content to align “center” horizontally and

c. set the font color to “Blue” and

d. set the font size to 25px and “bold” and e. add a “DropShadow” effect with offsetX to 15px and offset to 15px.

3. Add a textfield with a prompt text “Type your name here” to allow a user to enter a name.

4. Add a Generate button and its required functions to generate a use’s name on the text shape on the Start (e.g., John Wayne).

5. Add a Reset button and its required functions to reset all the controls back to the initial load conditions.

6. Set app title to “Draw a Super-Star”.

7. If the user hasn’t entered any name but the Generate button is  being clicked, the app will not change any things and it will stay in  its initial condition (refer to Figure-1 below).

8. You are required to create an app resembling to the app in the screenshot.

9. Verify the correctness of your app.

Show more
ANSWER

import javafx.application.Application;

import javafx.stage.Stage;

import javafx.scene.Scene;

import javafx.scene.layout.Pane;

import javafx.scene.shape.Polygon;

import javafx.scene.text.Text;

import javafx.scene.paint.Color;

import javafx.scene.text.Font;

import javafx.scene.text.FontPosture;

import javafx.scene.text.FontWeight;

import javafx.scene.effect.DropShadow;

import javafx.event.ActionEvent;

import javafx.event.EventHandler;

import javafx.scene.control.Button;

import javafx.scene.layout.HBox ;

import javafx.geometry.Pos;

import javafx.scene.layout.BorderPane;

import javafx.geometry.Insets;

import javafx.scene.control.TextField;

import javafx.scene.layout.GridPane;

import javafx.scene.shape.Circle;

public class HollywoodStar extends Application

{

@Override

public void start(Stage primaryStage)

{

Button btn = new Button("Generate");

Button btn2 = new Button("Reset");

TextField txtinput =new TextField();

double TEXT_X = 28;

double TEXT_Y = 50;

// Draw the star

Polygon star = new Polygon(100, 2, 40, 182, 194, 70, 4,70, 158, 182);

star.setStroke(Color.GOLD);

star.setStrokeWidth(5.0);

star.setFill(Color.AQUA);

Circle circle = new Circle(100,100,38);

circle.setFill(Color.AQUA);

Text name = new Text(TEXT_X, TEXT_Y, "Your-Name");

name.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 25));

name.setFill(Color.BLUE);

DropShadow shadow = new DropShadow();

shadow.setRadius(5.0);

shadow.setOffsetX(15);

shadow.setOffsetY(15);

shadow.setColor(Color.color(0.4, 0.5, 0.5));

name.setEffect(shadow);

// Add the shapes to a Pane.

Pane pane = new Pane(star, circle);

HBox box0 = new HBox();

box0.getChildren().add(name );

box0.setSpacing(13);

box0.setPrefWidth(80);

box0.setAlignment(Pos.CENTER );

GridPane gridPane = new GridPane();

//Setting the padding

gridPane.setPadding(new Insets(10, 10, 10, 10));

//Setting the vertical and horizontal gaps between the columns

//Setting the Grid alignment

gridPane.setAlignment(Pos.CENTER);

HBox box1 = new HBox();

box1.getChildren().addAll(btn,btn2 );

box1.setSpacing(13);

box1.setPrefWidth(80);

box1.setAlignment(Pos.BOTTOM_CENTER );

//Arranging all the nodes in the grid

// gridPane.add(textField1, 0, 0);

gridPane.add(pane,0, 0, 1, 1 );

gridPane.add(box0,0, 0, 2, 1 );

gridPane.add(txtinput,0, 1, 1, 1);

gridPane.add(box1, 0, 2, 1, 1);

//gridPane.add(btn2,1, 2, 1, 1);

gridPane.setVgap(10);

gridPane.setHgap(10);

btn.setOnAction(new EventHandler<ActionEvent>() {

@Override

public void handle(ActionEvent event) {

String textout = txtinput.getText();

 name.setText(textout);

}

});

btn2.setOnAction(new EventHandler<ActionEvent>() {

@Override

public void handle(ActionEvent event) {

txtinput.setText("");

name.setText("Your-Name");

}

});

// Create a Scene and display it.

Scene scene = new Scene(gridPane, 400, 350);

primaryStage.setScene(scene);

primaryStage.show();

}

public static void main(String[] args)

{

launch(args);

}

}

LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question