My borderlayout setup is messing up! please help!

I have the following setup:

MainPanel.add(toolbar, BorderLayout.NORTH);

MainPanel.add(toolbar2,BorderLayout.SOUTH);

ScrollPane.add(new JPanel.add(viewPanel));

MainPanel.add(ScrollPane,BorderLayout.WEST);

MainPanel.add(EastPanel,Borderlayout.East);

MainFrame.add(MainPanel);

Above is roughly my layout. I basically have 2 tool bars and 2 panels in a borderlayout and it displays as if my ScrollPane(west side) is taking over the space of the WEST and CENTER and my EastPanel is taking over the East side - just what I want.

The problem is sometimes my ScrollPane takes over the entire middle section of the MainFrame, taking out the EastPanel. Also, sometimes my scrollPane gets shifted all the way to the West and there is a gap in the Center. I basically just want a layout with two tool bars - one on top, one on bottom, and two panels in between - one is the main display panel and another panel on the side. The Frame is adjustable as well.

Can someone help me out with my problem? Is it the Scrollpane or BorderLayout tries to force the components back to a 5 region layout? The error doesn't come that often but it does happen. enough to be a concern.

Thank you!

[1239 byte] By [shaselaia] at [2007-11-27 7:34:07]
# 1

> The problem is sometimes my ScrollPane takes over the entire middle section of the MainFrame, taking out the EastPanel.

Never seen anything like this before.

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the posted code retains its original formatting.

camickra at 2007-7-12 19:14:32 > top of Java-index,Desktop,Core GUI APIs...
# 2

Hey. I can't really create a short executable since it wont be short and the behaviour doesn't come up that often in the first place. What I am trying to do is have 1 scrollpane and one other panel in the mid section, 1 toolbar on the top and bottom of the frame. Is there some Layout better than borderlayout to bring everything together? It might be borderlayout forcing the other unused section to appear , at least the spacing of it.

Thanks

shaselaia at 2007-7-12 19:14:32 > top of Java-index,Desktop,Core GUI APIs...
# 3
Like I said I've never seen this behavour in 8 years so you must be doing something really strange.There is nothing wrong with the BorderLayout I use it all the time for "bringing everything together".
camickra at 2007-7-12 19:14:32 > top of Java-index,Desktop,Core GUI APIs...
# 4

I think it may have something to do with not using the CENTER in the layout or using the scrollpane. In the API it says the CENTER will try to use all the unoccupied space so now I set the viewing panel to CENTER instead of WEST. Also, I noticed that my scrollpane somtimes take up the entire middle - getting rid of my EAST panel. Not sure why it does it. I have autoscroll on and I set the prefereed size of the panel within the bounds of the scrollpane. Again, these errors come randomly so I can't find what exactly is causing them to happen...

shaselaia at 2007-7-12 19:14:32 > top of Java-index,Desktop,Core GUI APIs...
# 5
possible alternativetoolbar - northtoolbar2 - southJSplitpane(scrollPane,eastpanel) - centerdisable the splitpane, so the divider is not moveable, and/or remove the divider
Michael_Dunna at 2007-7-12 19:14:32 > top of Java-index,Desktop,Core GUI APIs...