Guest User

Untitled

a guest
Sep 14th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 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. public class Main extends Application {
  22.  
  23. @Override
  24. public void start(Stage primaryStage) {
  25. primaryStage.setTitle("JavaFX Welcome");
  26. GridPane grid = new GridPane();
  27. grid.setAlignment(Pos.CENTER);
  28. grid.setHgap(10);
  29. grid.setVgap(10);
  30. grid.setPadding(new Insets(25, 25, 25, 25));
  31. Text scenetitle = new Text("Welcome");
  32. scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
  33. grid.add(scenetitle, 0, 0, 2, 1);
  34.  
  35. Label userName = new Label("User Name:");
  36. grid.add(userName, 0, 1);
  37.  
  38. TextField userTextField = new TextField();
  39. grid.add(userTextField, 1, 1);
  40.  
  41. Label pw = new Label("Password:");
  42. grid.add(pw, 0, 2);
  43.  
  44. PasswordField pwBox = new PasswordField();
  45. grid.add(pwBox, 1, 2);
  46. grid.setGridLinesVisible(false);
  47.  
  48. Button btn = new Button("Sign in");
  49. HBox hbBtn = new HBox(10);
  50. hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
  51. hbBtn.getChildren().add(btn);
  52. grid.add(hbBtn, 1, 4);
  53.  
  54. final Text actiontarget = new Text();
  55. grid.add(actiontarget, 1, 6);
  56.  
  57. btn.setOnAction(new EventHandler<ActionEvent>() {
  58.  
  59. @Override
  60. public void handle(ActionEvent e) {
  61. scenetitle.setId("welcome-text");
  62. actiontarget.setId("actiontarget");
  63. }
  64. });
  65.  
  66. Scene scene = new Scene(grid, 300, 275);
  67. primaryStage.setScene(scene);
  68. scene.getStylesheets().add
  69. (Main.class.getResource("Login.css").toExternalForm());
  70. primaryStage.show();
  71. }
  72.  
  73.  
  74. public static void main(String[] args) {
  75. launch(args);
  76. }
  77. }
Add Comment
Please, Sign In to add comment