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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Layout Managers

Status
Not open for further replies.

Nutthick

MIS
Jan 14, 2004
126
GB
I've been reading about layout managers and am still having trouble understanding the whole thing. I'm used to VB and giving an X/Y position plus a width and height. I understand (pretty much) why that isn't any good for cross platform use, but does anyone know of a good tutorial for the layout managers. A real idiot's version written by Mickey Mouse is what's required.

Thanks
 
Thanks stefanwagner, I've had a morning in Borders and am getting along better now. I've been needing to use GridBagLayout, but couldn't find anything written that made sense. Have got something that now looks more or less like what I want
 
Yeah, GridBagLayout is the most complex layout manager available. The API Javadoc is a little vague in some parts and I had to play around with some code to get a better feel for how it works.

... and I still sometimes end up resorting to trial-and-error to get things just as I want them.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
GridBagLayout is a nightmare to use. Like timw I often end up resorting to trial and error to get it right.

I spent a long time looking for a good online tutorial on how to use it but in the end found none.

I use the Netbeans IDE for java and it does have a GUI editor built in, with this it is possible to design your GridBagLayout GUI using a graphical editor then if you're really serious you can look at the code generated and work backwards and see how it's put together - personally I'm just happy when I get it looking how I want :)

If you want netbeans it's free from netbeans.org



Looking for a job as a programmer in Bristol UK.
 
To my mind, GridBagLayout is too complicated to design for (in general) an unpredicable result. I only use combinations of BorderLayout, GridLayout and FlowLayout and always got what I wanted. The only problem of this solution is that it raises the number of Jpanels used.

Water is not bad as long as it stays out human body ;-)
 
So what would people say is the best way to approach layouts? Does a good understanding of GridBagLayout stand you in better stead than using a combination of other to achieve the same?
 
Another choice is using a Visual Editor that will do layouts for you ...

Cheers,

Dian
 
To my mind, use only these 3 :
[ul]
[li] BorderLayout : very usefull because it autosizes the component placed CENTER to fill the panel.[/li]
[li] GridLayout : For components of the same size (for exemple, a label + field collection one above each other. In this case, empty JLabel can be used to leave one cell blank[/li]
[li] FlowLayout : for basic layout ( for exemple a button bar with "cancel" and "ok" buttons whose containing Jpanel should be placed SOUTH in main JPanel BorderLayout.[/li]
[/ul]

Water is not bad as long as it remains outside human body ;-)
 
I Agrees with Dian, Visual Editor plugin for Eclipse does a good job (and a huge but very clean code). Its leaks are a strong memory needs (that sometimes leads Eclipse to hang) and the fact that it doesn't know how to handle Swing that were not built using getters.

Water is not bad as long as it remains outside human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top