I have a JTable with autoResizeMode set to AUTO_RESIZE_LAST_COLUMN. I have added it to a panel by creating a JScrollPane with the JTable as its child widget, and then adding the JScrollPane to the panel.
I would like to set the size of the JScrollPane viewport to that of the parent JPanel, and have the JTable resize its last column dynamically.
JPanel have got implemented FlowLayout by defaut, you can place JScrollPane to the BorderLayout.CENTER
I think if you make the JPanel use GridLayout(1,1) and add the JScrollPane to it then you will get the desired result.
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