I want to create a panel with a table that fills all the available space.
I do this using the following code:
public class MyFrame extends JFrame { public EconomyFrame() throws HeadlessException { super("..."); final JTabbedPane tabbedPane = new JTabbedPane(); add(tabbedPane); final JPanel companiesPanel = new JPanel(); final CompaniesTableModel companiesModel = new CompaniesTableModel (ApplicationStateSingleton.INSTANCE.getPersistence().getCompanies()); final JTable companiesTable = new JTable(companiesModel); ApplicationStateSingleton.INSTANCE.getEventBus().subscribeToPropertyChanges(companiesModel); companiesPanel.add(new JScrollPane(companiesTable)); tabbedPane.addTab("Companies", companiesPanel); } }
But this does not work, because when I change the frame size, the table fills only part of the available space (see screenshots below).
How can I fix it (make the table fill all the available space)?


source share