Answer to Question #219338 in Java | JSP | JSF for Karon Aldrich

Question #219338

Write a JavaFX program that meets the following requirements 1) With your demonstration class, Implement a graphical window to display a game character setup dialog to allow the user to enter data into a visible window in order to set up the character object for the game (a) The dialog must provide a separate visual field for each data field, and include a textual label to the left of each field. 


1
Expert's answer
2021-07-21T01:55:16-0400
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

public class GUI extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        Label nameLabel = new Label("Name:");
        Label weaponLabel = new Label("Weapon:");
        Label healthLabel = new Label("Health:");

        TextField nameTextField = new TextField();
        TextField weaponTextField = new TextField();
        TextField healthTextField = new TextField();

        GridPane gridPane = new GridPane();
        gridPane.addRow(0,nameLabel);
        gridPane.addRow(1,weaponLabel);
        gridPane.addRow(2,healthLabel);

        gridPane.addColumn(1,nameTextField);
        gridPane.addColumn(1,weaponTextField);
        gridPane.addColumn(1,healthTextField);

        primaryStage.setScene(new Scene(gridPane));
        primaryStage.setTitle("Character Setup");
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS