Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.32 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("Button");
  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("label 1: ");
  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("label 2: ");
  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 dp = new StackPane(userName, enterName, password, enterPass, email, anotherText, bottomButton, button);
  84. //userName, enterName, password, enterPass, email, anotherText, bottomButton, button
  85.         //dp.getChildren().add(userName);
  86.         //dp.getChildren().add(enterName);
  87.         //dp.getChildre
  88.  
  89.         Scene scene = new Scene(dp, 800, 700);
  90.         primaryStage.setScene(scene);
  91.         primaryStage.show();
  92.  
  93.     }
  94.  
  95.     @Override
  96.     public void handle(ActionEvent event) {
  97.         if(event.getSource()==button)
  98.             System.out.println("you pressed a button");
  99.         //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  100.     }
  101.  
  102.  
  103.     /**T
  104.      * @param args the command line arguments
  105.      */
  106.     public static void main(String[] args) {
  107.         launch(args);
  108.     }
  109.  
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement