Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

TableView SmartResize

Edvin Syse edited this page Sep 6, 2016 · 10 revisions

WikiDocumentationTableView SmartResize

TableView SmartResize Policy

The JavaFX TableView is a powerful visualisation control used in almost every business application out there, but there has always been one critical part missing: The ability to resize columns intuitively, both by default and through configuration. As a result, many JavaFX applications are missing the polish and accessibility expected from today's business software.

The SmartResize.POLICY tries to bridge this gap by providing sensible defaults combined with powerful and dynamic configuration options.

Usage

To apply the resize policy to a TableView we configure the columnResizePolicy of the table:

tableView.columnResizePolicy = SmartResize.POLICY

For the wast majority of use cases, this is all you need to do. The default settings will try to give each column the space it needs based on it's content and give the remaining width to the last column. When you resize a column by dragging the divider between column headers, only the column immediately to the right will be affected, to avoid pushing the columns to the right outside the viewport of the TableView.

While this often presents a pleasant default, there is a lot more we can do to improve user experience. Each column can be customized with individual resize properties, which we will look at next.

  • Reevaluate resize rules after adding content via SmartResize.POLICY.requestXXX

Next: Error Handler

Clone this wiki locally