Friday, 10 February 2012

SwingBuilder Series: Layouts - BoxLayout

java.awt.BoxLayout allows multiple components to be laid out either vertically or horizontally. The SwingBuilder node for using de BoxLayout is boxLayout() . It is used the same as borderLayout() node was. You can declare the layout node, and then you can start adding components.

However each time you declare a new boxLayout() node, you should tell the layout what the components' direction is going to be: vertical or horizontal

There is a shortcut for using BorderLayout easier, java.awt.Box which is a container with a BoxLayout layout. There're two variants of the box() node: vbox(
) and hbox() for arranging component vertically or horizontally respectively.

These last two nodes are more popular for doing quick prototyping like the following sample:
import java.awt.BorderLayout as BL
import java.awt.Dimension
panel(preferredSize:new Dimension(500,200)){
comboBox(id:'language',preferredSize:new Dimension(125,0))

This code looks like this:


  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training JavaEE Training in Chennai Java EE Training in Chennai

  2. Really you have done great job,There are may person searching about that now they will find enough resources by your post

    Java training in Chennai

    Java training in Bangalore

  3. I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing..
    Believe me I did wrote an post about tutorials for beginners with reference of your blog. 

    Selenium training in bangalore
    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training

  4. Good Post! , it was so good to read and useful to improve my knowledge as an updated one, keep blogging.After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts likethis.