Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.14 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package sample;
  7.  
  8. import javafx.application.Application;
  9. import javafx.event.ActionEvent;
  10. import javafx.event.EventHandler;
  11. import javafx.scene.Scene;
  12. import javafx.scene.Parent;
  13. import javafx.geometry.Pos;
  14. import javafx.fxml.FXMLLoader;
  15. import javafx.scene.control.Button;
  16. import javafx.scene.control.Label;
  17. import javafx.scene.control.PasswordField;
  18. import javafx.scene.control.TextField;
  19. import javafx.scene.control.TextArea;
  20. import javafx.scene.layout.StackPane;
  21. import javafx.scene.layout.VBox;
  22. import javafx.stage.Stage;
  23.  
  24. /**
  25.  *
  26.  * @author nashmin
  27.  */
  28. public class Main extends Application implements EventHandler<ActionEvent>{
  29.     Button button;
  30.  
  31.     @Override
  32.     public void start(Stage primaryStage) {
  33.         primaryStage.setTitle("Login Window");
  34.  
  35.  
  36.         //the login button first
  37.         button = new Button();
  38.         button.setText("Login");
  39.         button.setTranslateX(200.0);
  40.         button.setTranslateY(300.0);
  41.         button.setMaxWidth(80.0);
  42.  
  43.         //another button
  44.         Button bottomButton = new Button();
  45.         bottomButton.setTranslateX(200.0);
  46.         bottomButton.setTranslateY(-150.0);
  47.         bottomButton.setMaxWidth(80.0);
  48.  
  49.         //username
  50.         Label userName = new Label("Username: ");
  51.         userName.setTranslateX(-270.0);
  52.         userName.setTranslateY(-250.0);
  53.  
  54.         //enter username
  55.         TextField enterName = new TextField();
  56.         enterName.setTranslateX(0.0);
  57.         enterName.setTranslateY(-250.0);
  58.         enterName.setMaxWidth((450));
  59.  
  60.         //password
  61.         Label password = new Label("Password: ");
  62.         password.setTranslateX(-270.0);
  63.         password.setTranslateY(-200.0);
  64.  
  65.         //entering secret code
  66.         PasswordField enterPass = new PasswordField();
  67.         enterPass.setTranslateX(0);
  68.         enterPass.setTranslateY(-200.0);
  69.         enterPass.setMaxWidth(450.0);
  70.  
  71.         //huge textArea
  72.         TextArea email = new TextArea();
  73.         email.setTranslateX(0);
  74.         email.setTranslateY(50.0);
  75.         email.setMaxSize(450.0, 350.0);
  76.  
  77.         //another textfield
  78.         TextField anotherText = new TextField();
  79.         anotherText.setTranslateX(0.0);
  80.         anotherText.setTranslateY(250.0);
  81.         anotherText.setMaxWidth(450.0);
  82.  
  83.         StackPane displayBox = new StackPane(userName, enterName, password, enterPass, email, anotherText, bottomButton, button);
  84.  
  85.  
  86.         Scene scene = new Scene(displayBox, 800, 700);
  87.         primaryStage.setScene(scene);
  88.         primaryStage.show();
  89.  
  90.     }
  91.  
  92.     @Override
  93.     public void handle(ActionEvent event) {
  94.         if(event.getSource()==button)
  95.             System.out.println("you pressed a button");
  96.         //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  97.     }
  98.  
  99.  
  100.     /**T
  101.      * @param args the command line arguments
  102.      */
  103.     public static void main(String[] args) {
  104.         launch(args);
  105.     }
  106.  
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement