Inconsistent layout w/dynamic resize of components

Hi

I'm developing a GUI component that should provide a single column of components I'll call MessageViews. Each MessageView consists of a JButton displayed above a JTextPane. I'm seeing what seems like inconsistent behavior in the way this component is laid out under different conditions.

Here is the behavior that I want: suppose the component contains two MessageViews, one above the other. The top button is labeled "Hide", and the top text pane is displaying text. The bottom button is labeled "Show" and no text is displayed. If you click the top button, the top text should disappear, and the bottom button and text should slide up to just below the top button.

I have an example (attached) that is about halfway to working. I have pared it down as small as I can (about 100 lines). Obviously the final component will be more polished.

When this is run, you can click the bottom button, and the text is displayed, no problem. Click the bottom button again, and the text is hidden. The button labels change as one would like. Click the top button, and the bottom button slides up to just below the top button, with no text showing anywhere, again as we would like. So far so good.

Now click the bottom button. The bottom text is shown, but the whole thing slides down to make space for the top text, which is not displayed. The bottom button should stay in place just below the top button. There are other, similar inconsistencies if you play with this thing awhile. Why is the action performed on the lower MessageView object affecting how the parent object lays out the top MessageView object? What am I missing, and what can I do to fix it?