Reputation: 375
I mean when I resize the frame to the left or right side the table automatically resizes itself but I want the same future when I resize it from down or up sides of the table. There is scroll for down and up but I want default size to be smaller.
In fact aJScrollPane.setSize()
doesn't work, aJPanel.setSize()
too. Can you help me?
Upvotes: 2
Views: 109
Reputation: 21243
If you are trying to restrict the number of rows the table displays by default, you can use JTable.setPreferredScrollableViewportSize(). For example for 10 rows you can do the following:
table.setPreferredScrollableViewportSize(
new Dimension(table.getPreferredScrollableViewportSize().width,
10 * table.getRowHeight()));
Note however, table rows can have variable heights. Also note, that hard-coding sizes in general can have side effects.
Upvotes: 1