-
JPanel expanding
I have a JPanel that is setup to a BoxLayout(Call it PanelA), that is inside of a JScrollPane.
I am adding multiple JPanels to PanelA inside the code(not the Netbeans Designer). Each of these JPanels contains a JTable. How can I get the JPanels to be large enough to hold all the rows in the jtable?
They keep defaulting to a size capable of displaying 25 rows. I know the Jtables are more than 25 rows because if I show the scrollbar for the individual tables, it scrolls down(maybe 100 more rows). So how can I get the JPanels that I am adding to automatically size large enough to display all the rows(without having to scroll)?
-
Re: JPanel expanding
I assume you are adding the tables to a scrollpane and then you add the scrollpane to the panel. Then, to prevent scrollbars from appearing you need to do:
Code:
table.setPreferredScrollableViewportSize(table.getPreferredSize());