Friday, February 10, 2012

JavaFX 2.0: HBox and VBox

The HBox layout pane arranging a series of nodes in a single row horizontally.
The VBox layout pane arranging a series of nodes in a single column vertically.

JavaFX 2.0: HBox and VBox
package javafx_layoutpanes;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
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) {
primaryStage.setTitle(" HBox & VBox");
Group root = new Group();

double width = 400;
double height = 300;

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

BorderPane borderPane = new BorderPane();
borderPane.setPrefSize(width, height);

HBox hbox = new HBox();
new Button("Top 1"),
new Button("Top 2"),
new Button("Top 3"),
new Button("Top 4"),
new Button("Top 5"));

VBox vbox = new VBox();
new Button("Left A"),
new Button("left B"),
new Button("left C"),
new Button("left D"),
new Button("left E"));

borderPane.setBottom(new Button("Bottom"));
borderPane.setCenter(new Button("Center"));
borderPane.setRight(new Button("Right"));


No comments:

Post a Comment