I have a window that looks like this:
What I want, is when user selects specific item from combobox
at the bottom, additional labels
and textfields
appears between buttons
and bottom textfield
, so it will look something like this:
For this I'm using an additional grid pane with height=0:
And when I simply add rows to that grid from builder, tabPane is being resized automatically and I get what I need as it shown on second picture. But when I'm trying to do it in code, like this:
ColumnConstraints col1 = new ColumnConstraints();
ColumnConstraints col2 = new ColumnConstraints();
ColumnConstraints col3 = new ColumnConstraints();
ColumnConstraints col4 = new ColumnConstraints();
ColumnConstraints col5 = new ColumnConstraints();
ColumnConstraints col6 = new ColumnConstraints();
myGrid.getColumnConstraints().addAll(col1,col2,col3,col4,col5,col6);
myGrid.add(new Label("Label"), 0, 0);
myGrid.add(new Label("Label"), 0, 1);
myGrid.add(new Label("Label"), 0, 2);
myGrid.add(new Label("Label"), 0, 3);
myGrid.add(new Label("Label"), 0, 4);
myGrid.add(new Label("Label"), 0, 5);
myGrid.add(new TextField(), 1, 0);
myGrid.add(new TextField(), 1, 1);
myGrid.add(new TextField(), 1, 2);
myGrid.add(new TextField(), 1, 3);
myGrid.add(new TextField(), 1, 4);
myGrid.add(new TextField(), 1, 5);
myGrid
- is that gridpane
with height=0 at the begginin. And I'm having such screen, with tabpane
not re-sized: What am I doing wrong? Could someone explain please?
BTW - on all other elements like HBox and other everywhere pref Height = USE_COMPUTED_SIZE
What have you tried so far?
I believe calling myGrid.autosize();
after adding all children should solve your problem.
Well, for me as a solution ("dirty" solution) worked this:
// Height set manually
tabPane.getScene().getWindow().setHeight(700);
If someone knows how to set it's height dynamically (depending on GridPane height), please, respond.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.