I am putting a JTable into a JScrollPane
But When I set JTable Auto Resizeable, then it won't have horizontal scroll bar.
if I set AUTO_RESIZE_OFF, then the Jtable won't fill the width of its container when the column width is not big enough.
So how can I do this:
Thanks
Я обнаружил, что все, что нужно, это включить
table = new JTable(model);
// this enables horizontal scroll bar
table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
, а затем, когда требуемая ширина и высота области просмотра были рассчитаны, включить
frame.getContentPane().add(new JScrollPane(table))
table.setPreferredScrollableViewportSize(new Dimension(width,height));