Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make a jscrollpane (containing a jtable) fill its container

Tags:

java

swing

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.

like image 577
Martin DeMello Avatar asked Feb 22 '23 14:02

Martin DeMello


2 Answers

JPanel have got implemented FlowLayout by defaut, you can place JScrollPane to the BorderLayout.CENTER

like image 152
mKorbel Avatar answered Feb 24 '23 03:02

mKorbel


I think if you make the JPanel use GridLayout(1,1) and add the JScrollPane to it then you will get the desired result.

like image 38
Ashwinee K Jha Avatar answered Feb 24 '23 03:02

Ashwinee K Jha