Input

package uk.ac.reading.cs2ja16.rdrohan; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.stage.Stage; public class moo extends Application { @Override public void start(Stage primaryStage) throws Exception { // TODO Auto-generated method stub //Creating a GridPane container GridPane grid = new GridPane(); grid.setPadding(new Insets(10, 10, 10, 10)); grid.setVgap(5); grid.setHgap(5); //Defining the Name text field final TextField config = new TextField(); config.setPromptText("Enter the configuration:"); config.setPrefColumnCount(10); config.getText(); GridPane.setConstraints(config, 0, 0); grid.getChildren().add(config); //Defining the Submit button Button submit = new Button("Submit"); GridPane.setConstraints(submit, 1, 0); grid.getChildren().add(submit); /*Defining the Clear button Button clear = new Button("Clear"); GridPane.setConstraints(clear, 1, 1); grid.getChildren().add(clear);*/ //Adding a Label final Label label = new Label(); GridPane.setConstraints(label, 0, 3); GridPane.setColumnSpan(label, 2); grid.getChildren().add(label); //Setting an action for the Submit button submit.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if ((config.getText() != null && !config.getText().isEmpty())) { String configurationIn = config.getText(); System.out.println("Thanks for the config: " + configurationIn); } else { label.setText("You have not left a comment."); } } }); primaryStage.setScene(new Scene(grid, 500,500)); primaryStage.show(); } public static void main(String[] args) { // TODO Auto-generated method stub Application.launch(args); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.