Guest User

Untitled

a guest
Jan 8th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.54 KB | None | 0 0
  1. package sample;
  2.  
  3. import javafx.application.Application;
  4. import javafx.event.ActionEvent;
  5. import javafx.event.EventHandler;
  6. import javafx.geometry.Insets;
  7. import javafx.geometry.Pos;
  8. import javafx.scene.Scene;
  9. import javafx.scene.control.Button;
  10. import javafx.scene.control.Label;
  11. import javafx.scene.control.PasswordField;
  12. import javafx.scene.control.TextField;
  13. import javafx.scene.layout.GridPane;
  14. import javafx.scene.layout.HBox;
  15. import javafx.scene.paint.Color;
  16. import javafx.scene.text.Font;
  17. import javafx.scene.text.FontWeight;
  18. import javafx.scene.text.Text;
  19. import javafx.stage.Stage;
  20.  
  21. import static javafx.geometry.HPos.RIGHT;
  22.  
  23. public class Main extends Application {
  24.  
  25.     @Override
  26.     public void start(Stage primaryStage) {
  27.         primaryStage.setTitle("JavaFX Welcome");
  28.         GridPane grid = new GridPane();
  29.         grid.setAlignment(Pos.CENTER);
  30.         grid.setHgap(10);
  31.         grid.setVgap(10);
  32.         grid.setPadding(new Insets(25, 25, 25, 25));
  33.  
  34.         Text scenetitle = new Text("Welcome");
  35.         scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
  36.         grid.add(scenetitle, 0, 0, 2, 1);
  37.  
  38.         Label userName = new Label("User Name:");
  39.         grid.add(userName, 0, 1);
  40.  
  41.         TextField userTextField = new TextField();
  42.         grid.add(userTextField, 1, 1);
  43.  
  44.         Label email=new Label("Email:");
  45.         grid.add(email,0,2);
  46.  
  47.         TextField emailTextField=new TextField();
  48.         grid.add(emailTextField,1,2);
  49.  
  50.         Label pw = new Label("Password:");
  51.         grid.add(pw, 0, 3);
  52.  
  53.         PasswordField pwBox = new PasswordField();
  54.         grid.add(pwBox, 1, 3);
  55.  
  56.  
  57.  
  58.         Button btn = new Button("Sign in");
  59.         HBox hbBtn = new HBox(10);
  60.         hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
  61.         hbBtn.getChildren().add(btn);
  62.         grid.add(hbBtn, 1, 4);
  63.  
  64.         final Text actiontarget = new Text();
  65.         grid.add(actiontarget, 0, 6);
  66.         grid.setColumnSpan(actiontarget, 2);
  67.         grid.setHalignment(actiontarget, RIGHT);
  68.         actiontarget.setId("actiontarget");
  69.  
  70.         btn.setOnAction(new EventHandler<ActionEvent>() {
  71.  
  72.             @Override
  73.             public void handle(ActionEvent e) {
  74.                 actiontarget.setFill(Color.FIREBRICK);
  75.                 actiontarget.setText(emailTextField.toString());
  76.             }
  77.         });
  78.  
  79.         Scene scene = new Scene(grid, 350, 275);
  80.         primaryStage.setScene(scene);
  81.         primaryStage.show();
  82.     }
  83.  
  84.     public static void main(String[] args) {
  85.         launch(args);
  86.     }
  87.  
  88. }
Add Comment
Please, Sign In to add comment