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)){
vbox{
hbox{
textField(id:'title')
comboBox(id:'language',preferredSize:new Dimension(125,0))
button(id:'executeButton',text:'Add')
}
scrollPane(){
table(id:'mess
ages'){
tableModel(){
propertyColumn(header:'language',propertyName:'language')
propertyColumn(header:'text',propertyName:'text')
}
}
}
}
}

This code looks like this:




3 comments:

  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete