1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class Formulario extends Application { @Override public void start(Stage primaryStage) { // Creamos la caja de texto y el botón TextField textField = new TextField(); Button button = new Button("Enviar"); // Creamos un contenedor para colocar los componentes VBox root = new VBox(); root.setPadding(new Insets(10)); root.setSpacing(10); root.getChildren().addAll(textField, button); // Creamos la escena y la mostramos Scene scene = new Scene(root, 300, 200); primaryStage.setScene(scene); primaryStage.setTitle("Formulario Simple"); primaryStage.show(); } public static void main(String[] args) { launch(args); } } |