How to make the TableColumn in the TableView take the width of the content (by the maximum length of the cell contents in this column)?
Something like fit to content. I looked for answers on the Internet, but I didn’t find anything worthwhile, although the TableView itself has this functionality - with a double-click on the column heading separator, the left column stretches to the content - exactly what you need, but I didn’t find a program call.

    1 answer 1

    I didn’t do it myself, but I’ll point out the approximate way: You can insert an arbitrary size policy.

    tableView.setColumnResizePolicy(Callback<TableView.ResizeFeatures,java.lang.Boolean> callback) 

    I know it looks scary, but the devil is not so scary as its name, here we define it:

     static class ColumnResizePolicy implements Сallback<TableView.ResizeFeatures, Boolean> { @Override public Boolean call(ResizeFeatures arg0) { //А тут из arg0 можно получить как таблицу так и колонку, для которой она применяется. } } 

      Protected by spirit community member 28 Apr '16 at 10:21 .

      Thank you for your interest in this issue. Since he collected a large number of low-quality and spam responses, which had to be deleted, now it’s necessary to have 10 reputation points on the site (the bonus for account association is not counted ).

      Maybe you want to answer one of the unanswered questions ?