Reputation: 455
I have a simple JavaFX application that has several textfields and 1 textarea in a gridpane, problem i'm having is that if place the textarea under any of the textfields they get resized to the size of the textarea. I need a way to make the textarea span multiple columns of the grid without affecting the other controls. this is how I am adding the controls:
grid.setRowIndex(lblDesc, 3);
grid.setColumnIndex(lblDesc, 2);
grid.setRowIndex(tfDesc, 4);
grid.setColumnIndex(tfDesc,2);
grid.getChildren().addAll(lblDesc, tfDesc);
Thanks Rick
Upvotes: 2
Views: 3168
Reputation: 4885
I'd recommend root.add(element, col, row, colSpan, rowSpan)
Where root
GridPane root = new GridPane();
root.setAlignment(Pos.TOP_LEFT);
root.setHgap(10);
root.setVgap(10);
root.setPadding(new Insets(50, 50, 50, 50));
//Add each element to the GridPane
//.add(element, column, row ,column span, row span) span must be >0
//row 0
root.add(sourceDirLabel, 0, 0, 2, 1);
//row1
root.add(sourceDirText,0, 1, 3, 1);
root.add(sourceDirBtn, 3, 1);
//row 2
root.add(outputDirLabel, 0, 2, 2, 1);
//row3
root.add(outputDirText,0, 3, 3, 1);
root.add(outputDirBtn, 3, 3);
//row4
root.add(runBtn, 0 , 4);
Upvotes: 2
Reputation: 38152
Did you have a look at the API and tried one of the methods which support spanning columns?
http://docs.oracle.com/javafx/2.0/api/javafx/scene/layout/GridPane.html
Upvotes: 0