Advertisement
Guest User

Untitled

a guest
Mar 19th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. public static void main(String[] args) {
  2. launch(args);
  3. }
  4.  
  5. @Override
  6. public void start(Stage primaryStage) {
  7. primaryStage.setTitle("JavaFX Welcome");
  8. GridPane grid = new GridPane();
  9. grid.setAlignment(Pos.CENTER);
  10. grid.setHgap(10);
  11. grid.setVgap(10);
  12. grid.setPadding(new Insets(25, 25, 25, 25));
  13.  
  14. Text scenetitle = new Text("Welcome");
  15. scenetitle.setId("welcome-text");
  16. grid.add(scenetitle, 0, 0, 2, 1);
  17.  
  18. Label userName = new Label("User Name:");
  19. grid.add(userName, 0, 1);
  20.  
  21. TextField userTextField = new TextField();
  22. grid.add(userTextField, 1, 1);
  23.  
  24. Label pw = new Label("Password:");
  25. grid.add(pw, 0, 2);
  26.  
  27. PasswordField pwBox = new PasswordField();
  28. grid.add(pwBox, 1, 2);
  29.  
  30. Button btn = new Button("Sign in");
  31. HBox hbBtn = new HBox(10);
  32. hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
  33. hbBtn.getChildren().add(btn);
  34. grid.add(hbBtn, 1, 4);
  35.  
  36. final Text actiontarget = new Text();
  37. grid.add(actiontarget, 1, 6);
  38. actiontarget.setId("actiontarget");
  39.  
  40. btn.setOnAction(new EventHandler<ActionEvent>() {
  41.  
  42. @Override
  43. public void handle(ActionEvent e) {
  44. actiontarget.setText("Sign in button pressed");
  45. }
  46. });
  47.  
  48.  
  49. Scene scene = new Scene(grid, 300, 275);
  50. primaryStage.setScene(scene);
  51. scene.getStylesheets().add(Login.class.getResource("Login.css").toExternalForm());
  52. primaryStage.show();
  53. } }
  54.  
  55. System.out.println("Login.css was not found");
  56. System.exit(-1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement