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
# 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.
# 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?