Advertisement
Guest User

giuseppeishot

a guest
Dec 5th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. import javafx.application.Application;
  2. import javafx.event.ActionEvent;
  3. import javafx.event.EventHandler;
  4. import javafx.scene.Scene;
  5. import javafx.scene.control.Button;
  6. import javafx.scene.layout.StackPane;
  7. import javafx.stage.Stage;
  8. import javafx.scene.layout.*;
  9. import javafx.geometry. *;
  10. import javafx.scene.control. *;
  11. import javafx.scene.text.*;
  12. import javafx.scene.paint.*;
  13.  
  14.  
  15. public class JavaFXForm extends Application{
  16.  
  17. public static void main(String[] args) {
  18. launch(args);
  19.  
  20. }
  21. @Override
  22. public void start(Stage primaryStage){
  23. primaryStage.setTitle("JavaFX Welcome");
  24.  
  25. primaryStage.show();
  26.  
  27. GridPane grid = new GridPane();
  28. grid.setAlignment(Pos.CENTER);
  29. grid.setHgap(10);
  30. grid.setVgap(10);
  31. grid.setPadding(new Insets (25, 25, 25, 25));
  32.  
  33. Scene scene = new Scene(grid, 300, 275);
  34. primaryStage.setScene(scene);
  35.  
  36. Text scenetitle = new Text("Welcome");
  37. scenetitle.setFont(Font.font("tahoma", FontWeight.NORMAL, 20));
  38. grid.add(scenetitle, 0, 0, 2, 1);
  39.  
  40. Label userName = new Label("UserName: ");
  41. grid.add(userName, 0, 1);
  42.  
  43. TextField userTextField = new TextField ();
  44. grid.add(userTextField, 1, 1);
  45.  
  46. Label pw = new Label ("Password: ");
  47. grid.add(pw, 0, 2);
  48.  
  49. PasswordField pwBox = new PasswordField();
  50. grid.add(pwBox, 1, 2);
  51.  
  52. //grid.setGridLinesVisible(true);
  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(new EventHandler<ActionEvent>() {
  64. @Override
  65. public void handle (ActionEvent e) {
  66. actiontarget.setFill(Color.FIREBRICK);
  67. actiontarget.setText("Sign in button pressed");
  68. }
  69. });
  70.  
  71. System.out.println("Hello");
  72. System.out.println(userTextField.getText());
  73.  
  74. System.out.println(pwBox.getText());
  75. }
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement