Grid_ImageView1
  • GridPane: allows the layout of child Nodes in a grid of rows and columns. The sizes of the rows and columns can be set as pixel measurements or, alternatively,percentages of the GridPane s size. In addition, each Node s alignment within its row and column can be set. GridPane s rows and columns start from 0, not 1

     
Code:

package javafxtemplate1;
//Grid_ImageView1.htm
//textProperty().addListener Listview Label
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;

/**
*
* @author Manas9
*/
public class JavaFXTemplate1 extends Application {

@Override
public void start(Stage primaryStage) throws Exception {
Group groot1 = new Group();
Image image1 = new Image(JavaFXTemplate1.class.getResourceAsStream("disk1.jpg"));
ImageView iv1 = new ImageView(image1);
iv1.setFitHeight(25);iv1.setFitWidth(25);
GridPane gridPane = new GridPane();
gridPane.setHgap(10);
//
Label label1 = new Label("label1");
Label label2 = new Label("label2");
Label label3 = new Label("label3");
//column 1, row 0
gridPane.add(label1,1,0);
gridPane.add(label2,2,0);
gridPane.add(label3,3,0);
gridPane.add(iv1, 5,0);
//Scene scene = new Scene(groot, 350, 150);
Scene scene = new Scene(gridPane, 250,100);
primaryStage.setScene(scene);
primaryStage.setTitle("Layout Control::GridPane");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

 
Display :