The problem I have is that when more rows are added to JTable (jtbls) the vertical scrollbar doesn’t appear on my JScrollPane (outer).
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(1, 4));
JScrollPane outer = new JScrollPane(panel);
jtbls = new JTable[4];
for (int i = 0; i < jtbls.length; i++) {
jtbls[i] = new JTable(new MyTableModel());
jtbls[i].setFillsViewportHeight(true);
jtbls[i].setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
JPanel inner = new JPanel(new BorderLayout());
inner.add(jtbls[i], BorderLayout.CENTER);
inner.add(jtbls[i].getTableHeader(), BorderLayout.NORTH);
inner.setPreferredSize(new Dimension(outer.getWidth() / 4, 70));
panel.add(inner);
}
add(outer);

This is because you set
So
innerJPanelis “fine” with height above70and don’t requests more space to the parent –JPanel panelwhich won’t request more space to its parent –JVieport.Also if you look at the source code of
JTable– methodsetFillsViewportHeightis only applicable to thejavax.swing.JLayer,javax.swing.ScrollPaneLayout,javax.swing.ViewportLayout(look at invocations ofgetScrollableTracksViewportHeight()) – so this will work only when JTable is inside some viewport.