A
A
artshelom2018-03-29 08:24:18
Java
artshelom, 2018-03-29 08:24:18

How to make a column full width?

I created a table in javafx and filled it with columns, but how to make the column always be the entire width of the table ??

TableColumn column = new TableColumn("asda");
        tableView.getColumns().add(column);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Kornachev, 2018-03-29
@artshelom

One column will stretch to full width.

TableView table = new TableView<Object>();
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

TableColumn column = new TableColumn("asda");
table.getColumns().add(column);

If you add more columns, then by default they will share the available width among themselves. The amount of width it takes depends on the maximum column width value. If the first column at the maximum is 3000px and the second is 6000px, then the first column will be 1/3 and the second 2/3.
In general, it's better to install SceneBuilder and experiment there. All possible settings are there, it will be clearer.

D
Dmitry Alexandrov, 2018-03-29
@jamakasi666

bind column width to table width like column.prefWidthProperty().bind(tableView.widthProperty())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question