Gridbag layout problem

Hi All,

I'm new to swing. i have used Gridbaglayout for panel and added some labels, buttons, textfields, etc there.

i want the components to spread through whole panel, but components are displayed in middle area of the panel.

How can i spread components in entire panel?

Any suggestion will be appreciated.

Thanks

[354 byte] By [ibmnewa] at [2007-10-2 18:09:32]
# 1
You should try, try, try and try and fully understand what GridBagConstraints and itsparameters do. Write many, five or ten, variations of a small test program and run them.
hiwaa at 2007-7-13 19:29:13 > top of Java-index,Desktop,Core GUI APIs...
# 2

Try to use fill constraint.You can use this constraint to fill the display area either horizontally,vertically or both.

GridBagLayout layout=new GridBagLayout();

GridBagConstraints constraints=new GridBagConstraints();

constraints.fill=GridBagConstraints.HORIZONTAL

//or u can give GriBagConstraints.VERTICAL or

//GridBagConstraints.BOTH

layout.setConstraints(yourcomponent,constraints)

Try to use the above for all your componets and see whether you get the required result.

Gcona at 2007-7-13 19:29:13 > top of Java-index,Desktop,Core GUI APIs...
# 3
try weightx and weighty.................try ipadx and ipady also
redwina at 2007-7-13 19:29:13 > top of Java-index,Desktop,Core GUI APIs...
# 4
Read the tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]How to Use GridBayLayout[/url] for explanations of the constraints and examples.
camickra at 2007-7-13 19:29:13 > top of Java-index,Desktop,Core GUI APIs...