Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

PROGRAMACIÓN EN AMBIENTES GRÁFICOS CON ACCESO A DATOS

Layouts

1)
package application;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;

public class Loyauts extends Application {


@Override
public void start(Stage primaryStage) {
primaryStage.setTitle(" 9 BOTONES");

GridPane gridPane = new GridPane();


gridPane.setPadding(new Insets(10));
gridPane.setHgap(10);
gridPane.setVgap(10);

for (int row=0; row<3; row++){


for (int col = 0; col < 3; col++){

Button button = new


Button("BOTON"+(row*3+col+1));
button.setPrefSize(200, 100);
gridPane.add(button, col, row);
}
}

Scene scene = new Scene(gridPane, 300, 200);


primaryStage.setScene(scene);
primaryStage.show();
}

public static void main(String[] args) {


launch(args);
}
}
2)
package application;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;

public class Loyauts extends Application {


@Override
public void start(Stage primaryStage) {
primaryStage.setTitle(" BOTONES INFERIORES ");

BorderPane bordePane = new BorderPane();


HBox hbox = new HBox(50);

Button bt = new Button("bt");


Button bt2 = new Button("bt2");
Button bt3 = new Button("bt3");

HBox.setMargin(bt, new Insets(0,10,0,0));


HBox.setMargin(bt2, new Insets(0,10,0,0));

bordePane.setBottom(hbox);
hbox.getChildren().addAll(bt, bt2, bt3);

Scene scene = new Scene(bordePane, 300, 300);


primaryStage.setScene(scene);
primaryStage.show();
}

public static void main(String[] args) {


launch(args);
}
}

You might also like