Guest User

Untitled

a guest
Jun 5th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. package com.company;
  2.  
  3. import javafx.geometry.Insets;
  4. import javafx.geometry.Pos;
  5. import javafx.application.Application;
  6. import javafx.event.ActionEvent;
  7. import javafx.event.EventHandler;
  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.layout.StackPane;
  16. import javafx.scene.paint.Color;
  17. import javafx.scene.text.Font;
  18. import javafx.scene.text.FontWeight;
  19. import javafx.scene.text.Text;
  20. import javafx.stage.Stage;
  21.  
  22. public class Main extends Application {
  23.  
  24. public static void main(String[] args) {
  25. launch(args);
  26. }
  27.  
  28. @Override
  29. public void start(Stage primaryStage) {
  30.  
  31. GridPane grid = new GridPane();
  32. grid.setAlignment(Pos.CENTER);
  33. grid.setHgap(10);
  34. grid.setVgap(10);
  35. grid.setPadding(new Insets(25,25,25,25));
  36.  
  37. Scene scene = new Scene(grid, 300, 275);
  38.  
  39. Text scenetitle = new Text("Please Login: ");
  40. scenetitle.setFont(Font.font("Tahoma",FontWeight.NORMAL, 20));
  41. Label userName = new Label("User Name: ");
  42. TextField userTextField = new TextField();
  43. Label pw = new Label("Password: ");
  44. PasswordField pwBox = new PasswordField();
  45.  
  46. grid.add(scenetitle,0,0,2,1);
  47. grid.add(userName,0,1);
  48. grid.add(userTextField,1,1);
  49. grid.add(pw,0,2);
  50. grid.add(pwBox,1,2);
  51.  
  52. grid.setGridLinesVisible(false);
  53.  
  54. Button btn = new Button("Sign in");
  55. HBox hbBtn = new HBox(10);
  56. hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
  57. hbBtn.getChildren().add(btn);
  58. grid.add(hbBtn,1,4);
  59.  
  60. final Text actiontarget = new Text();
  61. grid.add(actiontarget,1,6);
  62.  
  63. btn.setOnAction(event -> {
  64. actiontarget.setFill(Color.FIREBRICK);
  65. actiontarget.setText("Sign in button pressed");
  66. });
  67. scene.getStylesheets().add(Main.class.getResource("style.css").toExternalForm());
  68. primaryStage.setTitle("JavaFX Login Form");
  69. primaryStage.setScene(scene);
  70. primaryStage.show();
  71. }
  72. }
Add Comment
Please, Sign In to add comment