简体   繁体   中英

Horizontal scroll bar hides the last row in a TableView (JavaFX)

My problem is this: when a TableView has more rows than its height supports, a vertical scroll bar and a horizontal scroll bar appears. If the user goes to the bottom of the TableView and update the list that fills the TableView, the TabletView shows correctly all the ítems but the horizontal scroll bar partially hides the last row, if the user tries to scroll to bottom, the vertical scroll bar does not go to bottom and the last row remains hidden.

Question: is there any way or method that prevents the hiding of the last row in this situation?

If you actually do not need the horizontal scrollbar at all, you can do the following.

Set the column resize policy of the table view to CONSTRAINED_RESIZE_POLICY :

tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

Simple policy that ensures the width of all visible leaf columns in this table sum up to equal the width of the table itself.

Beside this, you can ensure that the horizontal scrollbar is invisible all the time.

To achieve that you can add the following lines to your CSS file:

.table-view .scroll-bar:horizontal .increment-arrow,
.table-view .scroll-bar:horizontal .decrement-arrow,
.table-view .scroll-bar:horizontal .increment-button,
.table-view .scroll-bar:horizontal .decrement-button {
    -fx-padding:0;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM