Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Make TableView height match content

1090038Nov 18 2014

I am placing a TableView (plus some other stuff) inside of a VBox, ultimately wrapped by a ScrollPane.  I'd like to use the ScrollPane for all scrolling, and have the table resize fit its content.  So if there are 3 rows, it's 3 rows high; if there are 100 rows, it's 100 rows high.

What's the best way to tell the table to do this?  The default seems to give me a fixed height of about 15 rows, regardless of how much data is included.  I can set a different fixed height, but I don't know how to correctly compute the height I want, and anyway that's just a workaround for having the table figure out its height on its own.

Putting this another way: TableViews automatically wrap their content in a (implicit?) scroll pane.  I'd like to turn that off.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 16 2014
Added on Nov 18 2014
0 comments
1,102 views