Write a JavaFX program that meets the following requirements(b) Include a graphical control to accept information for each of the following fields: 1) The textual name of the character 2). The textual nature of the character, e.g. ’good’ or ’evil’ .3) A comma separated, textual list of special skills, badges, achievements items or traits the character has. The list may be of length up to 100 characters (a string type)
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 natureLabel = new Label("Nature:");
Label otherLabel = new Label("Special skills, items, achievements or traits:");
TextField nameTextField = new TextField();
TextField natureTextField = new TextField();
TextField otherTextField = new TextField();
GridPane gridPane = new GridPane();
gridPane.addRow(0,nameLabel);
gridPane.addRow(1,natureLabel);
gridPane.addRow(2,otherLabel);
gridPane.addColumn(1,nameTextField);
gridPane.addColumn(1,natureTextField);
gridPane.addColumn(1,otherTextField);
primaryStage.setScene(new Scene(gridPane));
primaryStage.setTitle("Character Setup");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Comments
Leave a comment