Example usage for javafx.scene.layout GridPane setConstraints

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

Introduction

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

Prototype

public static void setConstraints(Node child, int columnIndex, int rowIndex) 

Source Link

Document

Sets the column,row indeces for the child when contained in a gridpane.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 200);
    stage.setScene(scene);// w  ww .  ja  va  2  s  . c  o  m

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

    scene.setRoot(grid);

    caption.setFont(Font.font("Verdana", 20));

    GridPane.setConstraints(caption, 0, 0);
    GridPane.setColumnSpan(caption, 8);
    grid.getChildren().add(caption);

    final Separator sepHor = new Separator();
    sepHor.setValignment(VPos.CENTER);
    GridPane.setConstraints(sepHor, 0, 1);
    GridPane.setColumnSpan(sepHor, 7);
    grid.getChildren().add(sepHor);

    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);/*w  w w . j  a  va  2 s .co  m*/
    stage.setTitle("Text Field Sample");

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

    scene.setRoot(grid);

    final TextField name = new TextField();
    name.setPromptText("Enter your first name.");
    name.setPrefColumnCount(10);
    name.getText();
    GridPane.setConstraints(name, 0, 0);
    grid.getChildren().add(name);

    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);//w  w w.  j av  a 2  s  . co m
    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:net.sourceforge.entrainer.gui.EntrainerFX.java

private void layoutComponents() {
    mainPanel = new JFXPanel();

    int v = 0;/*from w  ww  .  j a v a  2s.  co  m*/
    GridPane.setConstraints(sliderControlPane, 0, v++);
    GridPane.setMargin(sliderControlPane, new Insets(20, 0, 0, 0));
    GridPane.setConstraints(pictures, 0, v++);
    GridPane.setConstraints(animations, 0, v++);
    GridPane.setConstraints(shimmerOptions, 0, v++);
    GridPane.setConstraints(neuralizer, 0, v++);

    gp.setPadding(new Insets(5, 13, 5, 5));
    gp.getChildren().addAll(sliderControlPane, animations, shimmerOptions, pictures, neuralizer);

    hiddenSidesPane = new HiddenSidesPane();
    hiddenSidesPane.setContent(gp);
    hiddenSidesPane.setTop(soundControlPane);
    hiddenSidesPane.setTriggerDistance(25);

    final URI css = JFXUtils.getEntrainerCSS();

    JFXUtils.runLater(new Runnable() {

        @Override
        public void run() {
            group = new Group();

            shimmer.setInUse(true);
            group.getChildren().addAll(background.getPane(), shimmer, hiddenSidesPane);
            Scene scene = new Scene(group);
            if (css != null)
                scene.getStylesheets().add(css.toString());
            mainPanel.setScene(scene);
        }
    });

    getContentPane().add(mainPanel);
}