Monday, February 13, 2012

JavaFX 2.0: set width and height of Layout Pane - setPrefSize()

with borderPane.setPrefSize()
without borderPane.setPrefSize()
package javafx_layoutpanes;

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

* @web
public class JavaFX_LayoutPanes extends Application {

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

public void start(Stage primaryStage) {
Group root = new Group();
Scene scene = new Scene(root, 400, 300);

BorderPane borderPane = new BorderPane();
borderPane.setPrefSize(scene.getWidth(), scene.getHeight());

borderPane.setTop(new Button("Top"));
borderPane.setBottom(new Button("Bottom"));
borderPane.setCenter(new Button("Center"));
borderPane.setLeft(new Button("Left"));
borderPane.setRight(new Button("Right"));


No comments:

Post a Comment