Sunday, February 12, 2012

JavaFX 2.0: GridPane

JavaFX 2.0: GridPane
package javafx_layoutpanes;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class JavaFX_LayoutPanes extends Application {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com:");
Group root = new Group();

double width = 400;
double height = 300;

Scene scene = new Scene(root, width, height, Color.WHITE);

GridPane gridPane = new GridPane();

gridPane.add(new Text("0, 0"), 0, 0);
gridPane.add(new Button("0, 1"), 0, 1);
gridPane.add(new Text("1, 1"), 1, 1);
gridPane.add(new Button("1, 2"), 1, 2);
gridPane.add(new Button("1, 3"), 1, 3);
gridPane.add(new Button("2,3"), 2, 3);
gridPane.add(new Button("4, 0"), 4, 0);
gridPane.add(new Text("4, 2"), 4, 2);

root.getChildren().add(gridPane);
primaryStage.setScene(scene);
primaryStage.show();
}
}


No comments:

Post a Comment