1

I am making a table in SCALA using the ScrollPane, by creating a Table and RowHeader inside of the scrollpane, which lets me give the user the ability to resize my column widths. However, when there isn't much in this table yet, I get a bunch of empty vertical space. Is there a way to get the ScrollPane to autosize itself to what is inside of it?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Museless
  • 137
  • 2
  • 10

1 Answers1

0

On JTable, method setFillsViewportHeight is defined - so you can get it on your scala Table, too:

peer.setFillsViewportHeight(true)

This would give you the effect you want.

Rogach
  • 26,050
  • 21
  • 93
  • 172
  • I typed that into my definition and I get the following error: error: value setFillsViewportHeight is not a member of javax.swing.JScrollPane peer.setFillsViewportHeight(true) – Museless Nov 07 '11 at 19:18
  • Okay, so if I set the table to setFillsViewportHeight(true), The empty space is still there, it is just white now, as part of the table... is there a way to simply have the scrollpane itself resize to fit the data inside of it? – Museless Nov 07 '11 at 19:32
  • @Museless - so you want your whole window to shrink, if there is not enough data? – Rogach Nov 08 '11 at 04:09
  • Yes, that is exactly it. For some Tables in the database, there is a lot of data, and therefore, it this sizing is fine, but some tables only have 5-6 entries, and having the extra space there looks clumsy. I realise this is me being OCD at this point, I am just trying to see if this is even a feasibly solvable problem – Museless Nov 08 '11 at 04:33
  • @Museless - try calling frame.pack() on your root frame, after you have finished layouting and adding data to your table. Maybe it'll help, but it depends on layout manager and configuration you are using. – Rogach Nov 08 '11 at 08:42