jQuery in Action, 2nd edition*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Do use null layout is a bad idea? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Do use null layout is a bad idea?" Watch "Do use null layout is a bad idea?" New topic
Author

Do use null layout is a bad idea?

Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
Hi! I think that use null layout is a bad idea, but what do you think?

thanks
mohamed sulibi
Ranch Hand

Joined: Sep 04, 2005
Posts: 169
dear Leandro;

test it on different resolution setting and also on different machine contain same VM and resize your windows then see your windows if it is nice then go ahead , what you think ?

Best Regards.
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
mohamed sulibi wrote:dear Leandro;

test it on different resolution setting and also on different machine contain same VM and resize your windows then see your windows if it is nice then go ahead , what you think ?

Best Regards.


I'm not talking about it. I'm talking about if the examiners won't like if I use null layout.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2258
    
    3

Maybe it can be harder to maintain a window with null layouts... even though it may look good, you can lose some points in the UI marking criteria because of that...


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Julio Cesar Marques
Ranch Hand

Joined: Mar 21, 2009
Posts: 66
this is not explicitly included in the "instructions.html" so they can not deduct points if you justify in choices.txt


Julio Cesar Lopes Marques
Sun Certified Java Developer 5, Sun Certified Java Programmer 5
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5131
    
  12

Leandro,

Take a look at this link

A comparison between a null-layout and a FlowLayout. I think (like Roberto said already) you will loose some points for GUI for using it, because it's hard to maintain, more code, less flexible,... Adding an extra button will lead to a lot of recalculation you have to do.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
Thank you all for the explanations!
Roel, nice link, but the example favored FlowLayout. =D
I better comparison would be between null and GridBagLayout.

I found a very funny video about GridBagLayout http://madbean.com/anim/totallygridbag/
And a scare bug about GridBagLayout too ... http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4238932
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5131
    
  12

Leandro

Indeed, that's a really funny video And it has a bit of truth in it: with GBLayout you will end up with more code than null layout (every time setting the GBConstraints). But i think making changes to your form (adding a label, field,...) will be easier and faster though then when you have to recalculate everything.

I used the following layouts for all my panels:
- GridBagLayout
- BorderLayout
- FlowLayout
- BoxLayout (bu this one will be removed in favour of FlowLayout)

Kind regards,
Roel
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2242
    
    7

GridBag may be powerful but it surely needs whole bunch of constraints which can make "junior" programmers hard to follow. Remember one thing Sun examiners look for is "clarity and maintenability" .... so keep it straightforward.

I don't see why you need to use null layout. For me, I used BorderLayout, FlowLayout, and at times GridLayout throughout my GUI code. As long as you manage to place those components at the right places no fancy or gridbag layouts are needed.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Julio Cesar Marques
Ranch Hand

Joined: Mar 21, 2009
Posts: 66
I quit! I Was using null Layout too , but then I'll rewrite my gui package... these guys....

See you Later!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Do use null layout is a bad idea?
 
Similar Threads
Can't Get ScrollBar to Show
Adding component in JPanel
Pls Rate My proposed GUI concept for Assignment
Gui Re-Implementation or Modification
How to disable the [ - ] resizing of a frame