Guest User

Untitled

a guest
Jun 1st, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. package cliente;
  2.  
  3. import javafx.application.Application;
  4. import javafx.scene.Scene;
  5. import javafx.scene.layout.GridPane;
  6. import javafx.stage.Stage;
  7. import builder.gridBuilder;
  8.  
  9. public class Cliente extends Application {
  10.  
  11. public gridBuilder gB;
  12.  
  13. @Override
  14. public void start(Stage primaryStage) {
  15. GridPane grid = gB.creaLogin();
  16.  
  17. Scene scene = new Scene(grid, 700, 500);
  18.  
  19. primaryStage.setTitle("Room For You");
  20. primaryStage.setScene(scene);
  21. primaryStage.show();
  22. }
  23.  
  24. public static void main(String[] args) {
  25. launch(args);
  26. }
  27.  
  28. }
  29.  
  30. package builder;
  31.  
  32. import javafx.event.ActionEvent;
  33. import javafx.geometry.HPos;
  34. import javafx.geometry.Insets;
  35. import javafx.geometry.Pos;
  36. import javafx.scene.control.Button;
  37. import javafx.scene.control.Label;
  38. import javafx.scene.control.TextField;
  39. import javafx.scene.image.ImageView;
  40. import javafx.scene.layout.GridPane;
  41. import javafx.scene.paint.Color;
  42. import javafx.scene.text.Text;
  43.  
  44. public class gridBuilder{
  45.  
  46. public GridPane creaLogin(){
  47. GridPane grid = new GridPane();
  48.  
  49. grid.setAlignment(Pos.CENTER);
  50. grid.setHgap(10);
  51. grid.setVgap(10);
  52. grid.setPadding(new Insets(25));
  53. ImageView logo = new ImageView("imgs/logo.png");
  54. grid.add(logo, 0, 0, 2, 1);
  55. GridPane.setHalignment(logo, HPos.CENTER);
  56. GridPane.setMargin(logo, new Insets(0, 0, 20, 0));
  57.  
  58. Label userName = new Label("Nombre:");
  59. grid.add(userName, 0, 1);
  60. TextField userTextFied = new TextField();
  61. grid.add(userTextFied, 1, 1);
  62. Label password = new Label("Contraseña:");
  63. grid.add(password, 0, 2);
  64. TextField passTextField = new TextField();
  65. grid.add(passTextField, 1, 2);
  66.  
  67. Button btn = new Button("Iniciar Sesión");
  68. grid.add(btn, 1, 4);
  69.  
  70. Text actionTarget = new Text();
  71. grid.add(actionTarget, 0, 6);
  72. GridPane.setColumnSpan(actionTarget, 2);
  73. GridPane.setHalignment(actionTarget, HPos.CENTER);
  74.  
  75. btn.setOnAction((ActionEvent t) -> {
  76. actionTarget.setFill(Color.FIREBRICK);
  77. actionTarget.setText("Sign in button pressed");
  78. });
  79.  
  80. return grid;
  81. }
  82.  
  83. }
  84.  
  85. public class MyButton extends Button {
  86.  
  87. public MyButton() {
  88. Button button = new Button();
  89. button.setText("Say 'Hello World'");
  90. button.setOnAction((ActionEvent event) -> {
  91. System.out.println("Hello World!");
  92. });
  93. }
  94. }
  95.  
  96. public class ButtonBuilder {
  97.  
  98. public Button crearBoton1() {
  99. Button button = new Button();
  100. button.setText("Say 'Hello World'");
  101. button.setOnAction((ActionEvent event) -> {
  102. System.out.println("Hello World!");
  103. });
  104. return button;
  105. }
  106.  
  107. public Button crearBotonMuestraTexto(String text) {
  108. Button button = new Button();
  109. button.setText("Say '" + text + "'");
  110. button.setOnAction((ActionEvent event) -> {
  111. System.out.println(text);
  112. });
  113. return button;
  114. }
  115. }
Add Comment
Please, Sign In to add comment