Registration Form Example Using JavaFX

This is a simplest form for JavaFX registration layout, you can modify it whatever based on your need.

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class App extends Application  {
    private StackPane root = new StackPane();
    private Stage stage;

    @Override
    public void init() {
        Button button = new Button("OPEN");
        VBox vBox = new VBox();

        vBox.setSpacing(8);
        vBox.setPadding(new Insets(10,10,10,10));
        vBox.getChildren().addAll(
                new Label("Your Name"),
                new TextField(),
                new Label("Your Username"),
                new TextField(),
                new Label("Your Password"),
                new PasswordField(),
                new Label("Confirm Password"),
                new PasswordField(),
                new Button("REGISTER"));
        root.getChildren().addAll(vBox);

        button.setOnAction(actionEvent-> {
            if(stage!=null){
                stage.requestFocus();
                return;
            }
            stage = new Stage();
            StackPane stackPane = new StackPane();
            stage.setScene(new Scene(stackPane, 200,200));
            stage.show();
        });
    }

    @Override
    public void start(Stage primaryStage) {
        Scene scene = new Scene(root,400,600);
        primaryStage.setScene(scene);
        primaryStage.show();
        primaryStage.setTitle("Registration Example JavaFX");
        primaryStage.setAlwaysOnTop(true);
    }


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

JavaFX registration form example

Creating desktop application can be really hard, and the fact that there are three major desktop OS, Windows, MacOS and Linux, it can be time consuming to build three different code bases for three different OSes, but with the power of cross-platform Java, you can doing desktop development by just one single code base.

JavaFX is a great framework for your need to build desktop application, you can have the best development tools available and the maintainability of Java codes which is no questions you can build simple to large Application.

Popular posts from this blog

Spring Kafka - how to use ReplyingKafkaTemplate send and reply synchronously

How To Connect SSH Using PEM Certificate On Windows

ERROR 1348 Column Password Is Not Updatable When Updating MySQL Root Password

Flutter Button With Left Align Text and Icon

How To Create Spring Boot Project Using Netbeans