This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
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)
> 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.
> 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?
- 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?
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 ]
Joined: Aug 21, 2004
Michael and Terry, thank you very much for your time and kind help.