Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package cse327_studentadvisingsystem_javafx;
- import javafx.geometry.Insets;
- import javafx.application.Application;
- import javafx.event.ActionEvent;
- import javafx.event.EventHandler;
- import javafx.geometry.Pos;
- 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.GridPane;
- import javafx.scene.layout.HBox;
- import javafx.scene.paint.Color;
- import javafx.scene.text.Font;
- import javafx.scene.text.FontWeight;
- import javafx.scene.text.Text;
- import javafx.stage.Stage;
- /**
- *
- * @author muhib
- */
- public class LogIn extends Application {
- @Override
- public void start(Stage primaryStage) {
- primaryStage.setTitle("LogIn");
- //create a GridPanel Layout
- GridPane login_grid = new GridPane();
- login_grid.setAlignment(Pos.CENTER);
- login_grid.setHgap(10); //horizontal gap between components
- login_grid.setVgap(10);
- login_grid.setPadding(new Insets(25, 25, 25, 25));
- Text scenetitle = new Text("Welcome");
- scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
- login_grid.add(scenetitle, 0, 0, 2, 1);
- /*
- The grid.add() method adds the scenetitle variable to the layout grid.
- The numbering for columns and rows in the grid starts at zero, and
- scenetitle is added in column 0, row 0. The last two arguments of
- the grid.add() method set the column span to 2 and the row span to 1.
- */
- Label userName = new Label("User Name:");
- login_grid.add(userName, 0, 1);
- TextField userTextField = new TextField();
- login_grid.add(userTextField, 1, 1);
- Label pw = new Label("Password:");
- login_grid.add(pw, 0, 2);
- PasswordField pwBox = new PasswordField();
- login_grid.add(pwBox, 1, 2);
- //add button and HBox pane
- Button login_btn = new Button("Log in");
- HBox hblogin_btn = new HBox(10);
- hblogin_btn.setAlignment(Pos.BOTTOM_RIGHT);
- hblogin_btn.getChildren().add(login_btn);
- login_grid.add(hblogin_btn, 1, 4);
- final Text actiontarget = new Text();
- login_grid.add(actiontarget, 1, 6);
- login_btn.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle(ActionEvent e) {
- actiontarget.setFill(Color.FIREBRICK);
- actiontarget.setText("Sign in button pressed");
- }
- });
- Scene scene = new Scene(login_grid);
- primaryStage.setScene(scene);
- primaryStage.show();
- }
- }
Add Comment
Please, Sign In to add comment