I currently have JTables nested in JScrollPanes like so:
My problem is that the number of rows in each table is variable when the table is created. What I want to do is make the JScrollpane smaller if the table is too short, but I want to keep it at a set size if the table is too long.
How can I accomplish this?
Dimension d = table.getPreferredSize();
scrollPane.setPreferredSize(
new Dimension(d.width,table.getRowHeight()*rows+1));
Where rows
represents the number of rows of data, or the limit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With