JavaFX Login Example Codes
This is example of a login form created using JavaFX
JavaFX is good for creating cross-platform desktop application, you can literally doing simple UI to complex UI using JavaFX technology, it is my favorite framework powered by Java platform, you can build from simple to Enterprise level application, whatever application you want while codes is maintainable and can be deployed to wide variety of platform.
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 Username"), new TextField(), new Label("Your Password"), new PasswordField(), new Button("LOGIN")); 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("Login Example JavaFX"); primaryStage.setAlwaysOnTop(true); } public static void main(String[] args) { launch(args); } }
Login form javafx |
JavaFX is good for creating cross-platform desktop application, you can literally doing simple UI to complex UI using JavaFX technology, it is my favorite framework powered by Java platform, you can build from simple to Enterprise level application, whatever application you want while codes is maintainable and can be deployed to wide variety of platform.