I have created TableView in javafx using scenebuilder. It looks great in small window, but when I make it full screen it do not resize it's height but width only. And it also shows one extra empty column that I have not created. So please help me. I have just called fxml file of using using main.java class.
Asked
Active
Viewed 108 times
0
-
Possible duplicate of [JavaFx TableView Columns don't fill the TableView Width](https://stackoverflow.com/questions/44294622/javafx-tableview-columns-dont-fill-the-tableview-width) – fabian Aug 28 '18 at 21:55
-
Thanks.... I will try – Harshad Khandagale Aug 29 '18 at 07:26
1 Answers
0
You can solve those problems using bindings:
Column width:
If you want to be equally divided then:
first.prefWidthProperty().bind(tableView.widthProperty().divide(3)); last.prefWidthProperty().bind(tableView.widthProperty().divide(3)); email.prefWidthProperty().bind(tableView.widthProperty().divide(3));
Or instead of using
divide(3)
you can set any division for example: 40% 40% 20%Like:
double firstPercent = 0.4; double lastPercent = 0.4; double emailPercent = 0.2; // firstPercent + lastPercent + emailPercent = 1 !!! first.prefWidthProperty().bind(tableView.widthProperty().multiply(firstPercent)); last.prefWidthProperty().bind(tableView.widthProperty().multiply(lastPercent)); email.prefWidthProperty().bind(tableView.widthProperty().multiply(emailPercent));
TableView height:
tableView.prefHeightProperty().bind(content.heightProperty());
where the
content
is the reference of theVBox

Developer66
- 732
- 6
- 17

Sunflame
- 2,993
- 4
- 24
- 48