Is there a LayoutManager which will auto expand things on resize?

Say I want some JLabel aligned to the far left edge and then a button aligned to the far right edge. As the user resizes the frame these components will move to stay same distance from the edges no matter how big or small you resize.

I tried laying out some components with BorderLayout with one component WEST other one EAST and when I expand the window's width the components stay squished in the middle of the frame...

[435 byte] By [SpamFiltera] at [2007-10-2 16:59:54]
# 1
Try putting your label in the CENTER, which expands to fill the available space.Alternately, SpringLayout, BoxLayout with glue, and GridBagLayoutare all capable of doing this, as (I believe) are nested combinationsof FlowLayout and BorderLayout.
es5f2000a at 2007-7-13 18:13:20 > top of Java-index,Desktop,Core GUI APIs...
# 2
Pretty interesting history you have, particularly with adwebfinder. Pays to know... Sorry for not helping though!
da_wannabesa at 2007-7-13 18:13:20 > top of Java-index,Desktop,Core GUI APIs...
# 3
thanks es5f2000 , I will try SpringLayoutda_wannabes , adwebfinder ? :confused;
SpamFiltera at 2007-7-13 18:13:20 > top of Java-index,Desktop,Core GUI APIs...
# 4

> I tried laying out some components with BorderLayout with one

> component WEST other one EAST and when I expand the window's

> width the components stay squished in the middle of the frame...

Then you aren't doing what you described, because this will work and is probably the easiest solution. You must have nested LayoutManagers which is causing a problem.

You can also you a BoxLayout and use "glue" in between the two components. Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]How to Use Layout Managers[/url] for more information.

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] that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

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

camickra at 2007-7-13 18:13:20 > top of Java-index,Desktop,Core GUI APIs...
# 5
use JGoodies forms http://www.jgoodies.com/freeware/forms/
llpindda at 2007-7-13 18:13:20 > top of Java-index,Desktop,Core GUI APIs...
# 6
Yeah I have nested Layouts... but I'm only ever using BorderLayout ... BorderLayout breaks when you nest them?
SpamFiltera at 2007-7-13 18:13:20 > top of Java-index,Desktop,Core GUI APIs...
# 7
> BorderLayout breaks when you nest them? No. Read my previous reply. I'm not going to waste time guessing what your code looks like.
camickra at 2007-7-13 18:13:20 > top of Java-index,Desktop,Core GUI APIs...