Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cliente;
- import javafx.application.Application;
- import javafx.scene.Scene;
- import javafx.scene.layout.GridPane;
- import javafx.stage.Stage;
- import builder.gridBuilder;
- public class Cliente extends Application {
- public gridBuilder gB;
- @Override
- public void start(Stage primaryStage) {
- GridPane grid = gB.creaLogin();
- Scene scene = new Scene(grid, 700, 500);
- primaryStage.setTitle("Room For You");
- primaryStage.setScene(scene);
- primaryStage.show();
- }
- public static void main(String[] args) {
- launch(args);
- }
- }
- package builder;
- import javafx.event.ActionEvent;
- import javafx.geometry.HPos;
- import javafx.geometry.Insets;
- import javafx.geometry.Pos;
- import javafx.scene.control.Button;
- import javafx.scene.control.Label;
- import javafx.scene.control.TextField;
- import javafx.scene.image.ImageView;
- import javafx.scene.layout.GridPane;
- import javafx.scene.paint.Color;
- import javafx.scene.text.Text;
- public class gridBuilder{
- public GridPane creaLogin(){
- GridPane grid = new GridPane();
- grid.setAlignment(Pos.CENTER);
- grid.setHgap(10);
- grid.setVgap(10);
- grid.setPadding(new Insets(25));
- ImageView logo = new ImageView("imgs/logo.png");
- grid.add(logo, 0, 0, 2, 1);
- GridPane.setHalignment(logo, HPos.CENTER);
- GridPane.setMargin(logo, new Insets(0, 0, 20, 0));
- Label userName = new Label("Nombre:");
- grid.add(userName, 0, 1);
- TextField userTextFied = new TextField();
- grid.add(userTextFied, 1, 1);
- Label password = new Label("Contraseña:");
- grid.add(password, 0, 2);
- TextField passTextField = new TextField();
- grid.add(passTextField, 1, 2);
- Button btn = new Button("Iniciar Sesión");
- grid.add(btn, 1, 4);
- Text actionTarget = new Text();
- grid.add(actionTarget, 0, 6);
- GridPane.setColumnSpan(actionTarget, 2);
- GridPane.setHalignment(actionTarget, HPos.CENTER);
- btn.setOnAction((ActionEvent t) -> {
- actionTarget.setFill(Color.FIREBRICK);
- actionTarget.setText("Sign in button pressed");
- });
- return grid;
- }
- }
- public class MyButton extends Button {
- public MyButton() {
- Button button = new Button();
- button.setText("Say 'Hello World'");
- button.setOnAction((ActionEvent event) -> {
- System.out.println("Hello World!");
- });
- }
- }
- public class ButtonBuilder {
- public Button crearBoton1() {
- Button button = new Button();
- button.setText("Say 'Hello World'");
- button.setOnAction((ActionEvent event) -> {
- System.out.println("Hello World!");
- });
- return button;
- }
- public Button crearBotonMuestraTexto(String text) {
- Button button = new Button();
- button.setText("Say '" + text + "'");
- button.setOnAction((ActionEvent event) -> {
- System.out.println(text);
- });
- return button;
- }
- }
Add Comment
Please, Sign In to add comment