Source Code : Layout a Login Dialog
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Layout a Login Dialog
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.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("JavaFX 2 Login");
BorderPane bp = new BorderPane();
bp.setPadding(new Insets(10, 50, 50, 50));
HBox hb = new HBox();
hb.setPadding(new Insets(20, 20, 20, 30));
GridPane gridPane = new GridPane();
gridPane.setPadding(new Insets(20, 20, 20, 20));
gridPane.setHgap(5);
gridPane.setVgap(5);
Label lblUserName = new Label("Username");
final TextField txtUserName = new TextField();
Label lblPassword = new Label("Password");
final PasswordField pf = new PasswordField();
Button btnLogin = new Button("Login");
final Label lblMessage = new Label();
gridPane.add(lblUserName, 0, 0);
gridPane.add(txtUserName, 1, 0);
gridPane.add(lblPassword, 0, 1);
gridPane.add(pf, 1, 1);
gridPane.add(btnLogin, 2, 1);
gridPane.add(lblMessage, 1, 2);
btnLogin.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
}
});
bp.setTop(hb);
bp.setCenter(gridPane);
Scene scene = new Scene(bp);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Thank with us