Example usage for javafx.scene.layout GridPane GridPane

List of usage examples for javafx.scene.layout GridPane GridPane

Introduction

In this page you can find the example usage for javafx.scene.layout GridPane GridPane.

Prototype

public GridPane() 

Source Link

Document

Creates a GridPane layout with hgap/vgap = 0 and TOP_LEFT alignment.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>();
    emailComboBox.setItems(list);//  w  w  w. j ava2s.  c om
    emailComboBox.setValue("A");

    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>(list);

    emailComboBox.setValue("A");
    emailComboBox.setVisibleRowCount(3);

    GridPane grid = new GridPane();
    grid.setVgap(4);/*from   w  w  w  .  j a v a2  s.  c  o  m*/
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 600, 400);
    stage.setScene(scene);/*from w  ww.j av  a 2  s . c  om*/
    stage.setTitle("Slider Sample");

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(10);
    grid.setHgap(70);

    scene.setRoot(grid);

    GridPane.setConstraints(opacityCaption, 0, 1);
    grid.getChildren().add(opacityCaption);

    opacityLevel.valueProperty().addListener(new ChangeListener<Number>() {
        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            System.out.println(new_val.doubleValue());
            opacityValue.setText(String.format("%.2f", new_val));
        }
    });

    GridPane.setConstraints(opacityLevel, 1, 1);
    grid.getChildren().add(opacityLevel);

    GridPane.setConstraints(opacityValue, 2, 1);
    grid.getChildren().add(opacityValue);

    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>(list);

    emailComboBox.setValue("A");
    System.out.println(emailComboBox.getEditor());

    GridPane grid = new GridPane();
    grid.setVgap(4);//from   w w w  . j  ava 2s. c  o m
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(final Stage primaryStage) {
    primaryStage.setTitle("");
    Group root = new Group();
    Scene scene = new Scene(root, 400, 300, Color.WHITE);

    GridPane gridpane = new GridPane();

    ComboBox<Color> cmb = new ComboBox<Color>();
    cmb.getItems().addAll(Color.RED, Color.GREEN, Color.BLUE);

    cmb.setCellFactory(new Callback<ListView<Color>, ListCell<Color>>() {
        @Override// ww  w.  java  2  s .c  o  m
        public ListCell<Color> call(ListView<Color> p) {
            return new ListCell<Color>() {
                private final Rectangle rectangle;
                {
                    setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
                    rectangle = new Rectangle(10, 10);
                }

                @Override
                protected void updateItem(Color item, boolean empty) {
                    super.updateItem(item, empty);

                    if (item == null || empty) {
                        setGraphic(null);
                    } else {
                        rectangle.setFill(item);
                        setGraphic(rectangle);
                    }
                }
            };
        }
    });

    gridpane.add(cmb, 2, 0);

    root.getChildren().add(gridpane);
    primaryStage.setScene(scene);

    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>(list);

    emailComboBox.setValue("A");
    System.out.println(emailComboBox.getConverter());

    GridPane grid = new GridPane();
    grid.setVgap(4);/*from w w w.j  a  va 2 s  . c  o m*/
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>(list);

    emailComboBox.setValue("A");
    System.out.println(emailComboBox.getButtonCell());

    GridPane grid = new GridPane();
    grid.setVgap(4);/*from ww w.j  av a 2  s.c  om*/
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>(list);

    emailComboBox.setValue("A");
    System.out.println(emailComboBox.itemsProperty());

    GridPane grid = new GridPane();
    grid.setVgap(4);/*from  www. jav  a 2s.  c  o  m*/
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>(list);

    emailComboBox.setValue("A");
    System.out.println(emailComboBox.editorProperty());

    GridPane grid = new GridPane();
    grid.setVgap(4);//  ww  w  .  ja  v a 2s.c om
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>(list);

    emailComboBox.setValue("A");
    System.out.println(emailComboBox.getCellFactory());

    GridPane grid = new GridPane();
    grid.setVgap(4);/*from  w  w w.  j  a v  a2  s  . c o m*/
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}