JavaFX TableColumns headers do not match cells due to vertical scrollbar

After spending the last few hours on the Internet on this issue, I decided that I need your help.

The problem is similar to this topic: Javafx: Table header is not row bound

No answer was provided there, and also, I think, my case is slightly different:

Screenshot directly after launch

Screenshot after scrolling or clicking

I have a properly configured TableView with reusable CellFactories and CellValueFactories. According to the data, everything works 100% as I expected. However, as soon as I filled the table with more rows than my view could show, naturally I started to show a vertical scroll bar. From now on (see First Screenshot), the column headers were no longer aligned with the columns. It seems that it is the scrollbar width that distorts the width distribution (I use ConstraintResizePolicy with several columns with a fixed width, and the rest rely on the calculated width, again, work flawlessly).

As soon as I scroll with the mouse wheel, click on the record, the tab in focus or change the size of the window / view, the headers will snap into place (see the second screenshot).

, , , , ( ), . :

  • table.scrollTo()
  • table.scrollToColumnIndex()
  • table.layout()
  • table.requestFocus()
  • table.requestLayout()
  • table.refresh()

, , , .

. , , , - . SceneBuilder 8 AnchorPane, TableView 6 TableColumns, .

!

+4
1

. , . .

Platform.runLater(() -> tableView.refresh());
+3

All Articles