Created
June 5, 2017 21:41
-
-
Save alvareztech/993c9701ca236bffe64ece20b0becf05 to your computer and use it in GitHub Desktop.
JavaFX: GridPane Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.geometry.Insets; | |
import javafx.scene.Scene; | |
import javafx.scene.control.Button; | |
import javafx.scene.layout.GridPane; | |
import javafx.stage.Stage; | |
public class Main extends Application { | |
public static void main(String[] args) { | |
launch(args); | |
} | |
@Override | |
public void start(Stage primaryStage) throws Exception { | |
Button unoButton = new Button("Uno"); | |
Button dosButton = new Button("Dos"); | |
Button tresButton = new Button("Tres"); | |
Button cuatroButton = new Button("Cuatro"); | |
Button cincoButton = new Button("Cinco"); | |
unoButton.setMinWidth(80); | |
dosButton.setMinWidth(80); | |
tresButton.setMinWidth(80); | |
cuatroButton.setMinWidth(80); | |
cincoButton.setMinWidth(80); | |
GridPane gridPane = new GridPane(); | |
gridPane.setPadding(new Insets(20)); | |
gridPane.setHgap(20); // Espacio entre columnas | |
gridPane.setVgap(20); // Espacio entre filas | |
gridPane.add(unoButton, 0, 0); | |
gridPane.add(dosButton, 1, 0); | |
gridPane.add(tresButton, 2, 0); | |
gridPane.add(cuatroButton, 0, 1); | |
gridPane.add(cincoButton, 2, 1); | |
Scene scene = new Scene(gridPane, 400, 300); | |
primaryStage.setScene(scene); | |
primaryStage.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment