• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

So many Layouts?

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have used java since many years ago (mostly for web applications) but it has not been until recently that I have become interested in Swing.

Simply I used to program with Delphi and Visual C++. Now I am preparing myself to write windows form applications with swing instead of those.

1- My question: in delphi and VC++ we simply have a single layout! Put the component on the form , it will save its position (x,y) and its width and height. That's all. Now would someone please tell me the philosophy of having so many layouts?

2- Why we do not stick with SpringLayout for example and do everything with it? Can I stick with it without need of others? (Sorry that I do not understand)

3- NetBeans uses a GroupLayout in its Form Designer. Is this better than SpringLayout?

4- Can I safely stick with NetBeans form designer and let it do coding for form designs? Or I should bother myself about details?

Regards,
Mac
[ December 19, 2006: Message edited by: Siamak Saarmann ]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> in delphi and VC++ we simply have a single layout!

when I was active in the vb6 newsgroups, the #1 faq dealt with resizing/resolution
problems, and there was no definitive solution - everyone had a different
preferred solution. What worked in one situation didn't work in another etc.
Ans sometimes, with absolute positioning, different graphics cards were the problem.

I'd imagine it being the same for delphi and vc++.

Swing's layout managers handle it all for you - all you have to do is understand
how each layout manager works, then, with a little imagination, nest the
appropriate managers to get the desired effect - and the outcome will always
be better than absolute positioning.

About the only time a null layout would be useful is if the application
allowed the user to move the components around the container to suit the
user's preference.

> 4- Can I safely stick with NetBeans form designer and let it do coding for
> form designs? Or I should bother myself about details?

Standard answer: if you intend only building one application - netbeans is fine.
Otherwise, take the time to learn swing (using a simple ide) - it will be
worth the effort in the long run.

couple of links
http://java.sun.com/docs/books/tutorial/uiswing/TOC.html
http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> Now would someone please tell me the philosophy of having so many layouts?

- Resizablilty
- Doesn't assume you have IDEs (not everyone can run power/ram hungry IDEs ... people like me still depend a lot on NotePads and EditPluses)
- Ease of readiblity.
is
content.add(toolbar);
toolbar.setBounds(0,0,10,100);
easier?

or
content.add(toolbar, BorderLayout);
easier?

- Doesn't assume you use the same IDE.
Forms you create in JBuilder can't (be easily) viewed in Netbeans right.
Well, when I started, the forms/codes i took over that were written in JBuilder can't even be viewed in JBuilder. It was a tough time then....



> 2- Why we do not stick with SpringLayout for example and do
> everything with it? Can I stick with it without need of others?

As long as you feel it fits your needs and is easily maintainable, why not?


> 3- NetBeans uses a GroupLayout in its Form Designer.
> Is this better than SpringLayout?

There's no such thing as a better layout. Each has their own use and place.

Take for example, GridbagLayout. its the most versatile layout available on jdk. Most complex java ui use that. (at least before JGoodies)
The only problem with it is its verboseness and difficulty to code and read.
Its a layout that more suited for IDE builder.

Note that Springlayout is available only from 1.4 onwards, so using in systems such as 1.3 will require some effort.




> 4- Can I safely stick with NetBeans form designer and let it do coding
> for form designs? Or I should bother myself about details?

Sure, why not. As long as you don't mind being stuck to NetBeans, its not a bad idea at all.

OTOH IIRC do note that group-layout library is LGPL licenced. If your company has problems with that, then beware.

If that's the case, I'd recommend using JGoodies FormLayout, which is easily readable and maintainable as well as BSD licenced.

For the form builder, I highly recommend JFormdesigner. IMHO its the BEST java form designer currently. It supports JGoodies FormLayout and all the jdk layouts except for SpringLayout. Though its not free.

Not that, I'm not related to both JGoodies nor JFormdesigner. I'm just a very very happy customer.



In summary, it all boils down to personal preference.


[ December 19, 2006: Message edited by: Terry Ong ]
 
Siamak Saarmann
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael and Terry, thank you very much for your time and kind help.

Regards,Mac
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ye,i am a beginner.thank you for your opinions.
 
reply
    Bookmark Topic Watch Topic
  • New Topic