Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I set size of a panel with basic layout managers (BorderLayout) ?

Status
Not open for further replies.

sergeiY

Programmer
Feb 13, 2003
132
AU
I have 3 panels: left, center and right.

Left and right are just for padding they don't carry any elements but I would like to set them to be a specific size to push in center panel or alternatevly I would like to set size of center panel ... I've tried to use GridBag Layout but couldn't get it working... and I don't have any GUI building IDE so I really have to do it by hand...

Thank you
 
The only layout manager that respects your components size is FlowLayout.

Building a GUI requires that you think in terms of nesting panels within other panels.

For instance, I start with a main panel the size of the frame and add a BoxLayout manager to it. That allows me to build rows of components.

Each row has a panel with it's own layout manager - some use flowlayout with spacer panels, some use gridlayout, some use borderlayout. Sometimes I'll have a row that uses gridlayout and each cell of the grid contains a panel that uses flowlayout or something else.

I've found this to be easier than trying to lay out an entire screen with a single layout manager.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top