Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 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.fxml.FXMLLoader;
  7. import javafx.geometry.Insets;
  8. import javafx.scene.Parent;
  9. import javafx.scene.Scene;
  10. import javafx.scene.control.Button;
  11. import javafx.scene.control.TextField;
  12. import javafx.scene.layout.*;
  13. import javafx.scene.control.Label;
  14. import javafx.stage.Stage;
  15.  
  16. public class Main extends Application {
  17.  
  18. Stage window;
  19.  
  20. public static void main(String[] args) {
  21. launch(args);
  22. }
  23.  
  24. @Override
  25. public void start(Stage primaryStage) throws Exception{
  26. window = primaryStage;
  27. window.setTitle("title");
  28.  
  29. GridPane grid = new GridPane();
  30. grid.setPadding(new Insets(10,10,10,10));
  31. grid.setVgap(8);
  32. grid.setHgap(10);
  33.  
  34. Label nameLabel = new Label("Username: ");
  35. GridPane.setConstraints(nameLabel,0,0);
  36.  
  37. TextField nameInput = new TextField();
  38. nameInput.setPromptText("Type name here");
  39. GridPane.setConstraints(nameInput,1,0);
  40.  
  41.  
  42. Label passwordLabel = new Label("Password: ");
  43. GridPane.setConstraints(nameLabel,0,1);
  44.  
  45. TextField passwordInput = new TextField();
  46. passwordInput.setPromptText("Type password here");
  47. GridPane.setConstraints(passwordLabel,1,1);
  48.  
  49.  
  50. Button login = new Button("Log In");
  51. GridPane.setConstraints(login,1,2);
  52.  
  53.  
  54. grid.getChildren().addAll(nameLabel,nameInput,passwordLabel,passwordInput,login);
  55.  
  56. Scene scene = new Scene(grid,300,200);
  57. window.setScene(scene);
  58. window.show();
  59.  
  60.  
  61.  
  62.  
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement