Resizing a JScrollPane
Hi, I have a JScrollPane that contains a JTable inside. Basically, when a user clicks a button or selects an option, the Table Model changes and the table is populated with a different set of data, of a different size. The scrollpane starts off at a size of 500x255, but sometimes there are only a few rows of data to display, and the rest of the scrollpane shows up (below the table) as grey space. An example would be like this:
http://img205.imageshack.us/img205/4899/grrrlu2.png
I've been trying everything I can think of, and I can't get it to work properly. I've tried this:
if(skillTable.getHeight() <= 255){
scrollPane.setPreferredSize(new Dimension(500,skillTable.getHeight() + 19));
scrollPane.revalidate();
}
else{
scrollPane.setPreferredSize(originalDimensions);
scrollPane.revalidate();
}
and it doesn't update right away... I need to click another option (or the same one) again to get it to resize properly. So basically, if I click the same button twice, the pane resizes. If I click one button, then another, it resizes the pane to what the size should've been when I clicked the previous button. Does nayone have any idea what might be causing this? Thanks in advance!

