The code below doesnt do what it has to do. I need to place the components on the top left of my panel. But the components be still in the center of panel after giving this also gbc.anchor=GridBagConstraints.NORTHWEST; It doent work until i set gbc.weightx=0.0; and gbc.weighty=0.0;. Here the components get at the top position but the gap in between them is increasing. Someone please help me out. The code is here.
Can any one please suggest me to use which layout. I really want to know that which layout is good. I am good in GroupLayouts. Now please suggest me that that sahll i continue with grouplayout or change to other layout.
often a good layout manager is a combination of different layout managers to achieve the desired effect. In that sense, I would say it is difficult to recommend a specific layout for your situation.
The article is very good at describing how to use a combination of different Layout Managers to achieve the desired result.
Try to break your GUI into high level sections, whereby you can describe the layout of these sections relative to each other using a known manager. Then, you can describe the layout within each section by using it's own layout manager. Sort of a nesting of simple layout managers to achieve a more complex end result.
If you could show a picture of your desired layout, it would be easier to advise of specific layout managers to use.
Thanks for your example i am able to got little bit into my head and added a label and textfield now the problem is that they are getting placed in the center. When i increase the weigtx and weighty i am able to place in the correct position but i have observed that the value is needed to be increased by 50 and for other row again i have to add more two zeros that is 5000 then only i am getting the components in correct position. Please execute the code if you can. Then you can get my problem. The code is here.
Thanks a lot guyz i have learn t lot about the GridBagLayout. No i have got a simple doubt in the code below. When i arrange the components in the following order
l1 t1 l2 t2
its ok. i can arrange them, but when i reduce the size of t1 i.e t3 is 25 and t1 is 10 then gap between t1 and l2 is increased that is l2 and t2 remains at there old place only. How can i move them closer.