SpringLayout Constraint issues

Odd problem, when I add a button to chatPanel with the given constraints it fills the chatPanel as it should and the chatPanel fills its area as it should as well. But when I add a text area the north, south, and eastern constrains are obeyed but the western constraint is completely ignored and extends all the way to western border of the gui area. Here's the code:

JButton but =new JButton("test");

chatPanel.add(messageBoard);

layout.putConstraint(SpringLayout.EAST, messageBoard, 0, SpringLayout.EAST, chatPanel);

layout.putConstraint(SpringLayout.WEST, messageBoard, 0, SpringLayout.WEST, chatPanel);

layout.putConstraint(SpringLayout.SOUTH, messageBoard, 0, SpringLayout.SOUTH, chatPanel);

layout.putConstraint(SpringLayout.NORTH, messageBoard, 0, SpringLayout.NORTH, chatPanel);

If messageBoard, a text area, was a button it works fine but I don't have a clue as to why. Is there something special about text areas for which I should take account for? I would greatly appreciate some help.

Message was edited by:

RodSerling

[1163 byte] By [RodSerlinga] at [2007-11-27 6:28:05]
# 1

> >JButton but = new JButton("test");

> nel.add(messageBoard);

> layout.putConstraint(SpringLayout.EAST,

> messageBoard, 0, SpringLayout.EAST, chatPanel);

> layout.putConstraint(SpringLayout.WEST,

> messageBoard, 0, SpringLayout.WEST, chatPanel);

> layout.putConstraint(SpringLayout.SOUTH,

> messageBoard, 0, SpringLayout.SOUTH, chatPanel);

> layout.putConstraint(SpringLayout.NORTH,

> messageBoard, 0, SpringLayout.NORTH, chatPanel);

>

>

>

i don't think you are doing the east or the west correcly. the way i know it to work is you are linking the specified edge of the first component to the specified edge of the second.

it seems like you are trying to link the west edge of the first to the west edge of the second.

try linking the west edge of the first to the east edge of the second.

JacobsBa at 2007-7-12 17:50:26 > top of Java-index,Desktop,Core GUI APIs...
# 2

I'm a bit confused, why would I want the west of the messageBoard at the east of the chatPanel? I want the messageBoard to completely fill the chatPanel. messageBoard's western border should be right along chatPanel's western border. Again, for some odd reason when I try to do this chatPanel's western border ignores completely where its western border should be and extends to the far west of the frame and thus messageBoard is to the far west of the frame as well. This does not happen when I try to have a button fill chatPanel, it works perfectly fine then.

RodSerlinga at 2007-7-12 17:50:26 > top of Java-index,Desktop,Core GUI APIs...
# 3

i'm sorry, i thought you wanted them side by side.

i'm still having trouble understanding exactly what you mean though.

i understand that you want the messageBoard to completely fill the chatPanel.

are you saying that when you use the western contraints, the chatPanel's western boarder is moving to the west instead of the messageBoard?

also, why would you use this constraint on the messageBoard and chatPanel if the messageBoard is filling the chatPanel?

JacobsBa at 2007-7-12 17:50:26 > top of Java-index,Desktop,Core GUI APIs...
# 4

chatPanel is to the right of another panel called optionPanel. So within the frame that chatPanel and optionPanel are in, optionPanel is to the far left and chatPanel is just right of optionPanel. When I add only a button to chatPanel so that it completely fills chatPanel, everything works fine. The button completely fills chatPanel and chatPanel is just to the right of optionPanel as intended. If I only add a text area so that it completely fills chatPanel the southern, northern, and eastern edges are exactly where they should be. But the western border goes right over optionPanel to the western edge of the frame itself. I hope this give a picture of what exactly is happening.

RodSerlinga at 2007-7-12 17:50:26 > top of Java-index,Desktop,Core GUI APIs...
# 5

ok now i have a better idea of what you mean.

one more quick question though:

does the western boarder of the messageBoard go over the border of the chatPanel and the chatPanel remain the same, or is the actual chatPanel being stretched to the left as well...with the messageBoard still being completely contained within it?

JacobsBa at 2007-7-12 17:50:26 > top of Java-index,Desktop,Core GUI APIs...
# 6
The latter, messageBoard is completely in chatPanel and chatPanel is going to the far western border of the frame as well as messageBoard.
RodSerlinga at 2007-7-12 17:50:26 > top of Java-index,Desktop,Core GUI APIs...