Guest User

Untitled

a guest
Feb 2nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. public class JavaFx1 extends Application {
  2.  
  3. @Override
  4. public void start(Stage primaryStage) {
  5. primaryStage.setTitle("JavaFX Welcome");
  6.  
  7. GridPane grid = new GridPane();
  8. grid.setAlignment(Pos.CENTER);
  9. grid.setHgap(10);
  10. grid.setVgap(10);
  11. grid.setPadding(new Insets(25, 25, 25, 25));
  12. Scene scene = new Scene(grid, 300, 275);
  13.  
  14. Text scenetitle = new Text("Welcome");
  15. scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
  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.  
  39. btn.setOnAction((ActionEvent e) -> {
  40. actiontarget
  41. .setFill(Color.FIREBRICK);
  42. actiontarget.setText("Sign in button pressed");
  43. });
  44.  
  45. primaryStage.setScene(scene);
  46. primaryStage.show();
  47. }
  48.  
  49. /**
  50. * @param args the command line arguments
  51. */
  52. public static void main(String[] args) {
  53. launch(args);
  54. }
  55.  
  56. }
Add Comment
Please, Sign In to add comment