我遇到的问题是,当更多行添加到 JTable (jtbls) 时,垂直滚动条不会出现在我的 JScrollPane(外部)上。
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);