Tab Boxes

Components: tabbox, tabs, tab, tabpanels and tabpanel.

A tab box allows developers to separate a large number of components into several groups, and show one group each time, such that the user interface won't be too complicate to read. There is only one group (aka., a panel) is visible at the same time. Once the tab of an invisible group is clicked, it becomes visible and the previous visible group becomes invisible.

The generic syntax of tab boxes is as follows.

<tabbox>
    <tabs>    
        <tab label="First"/>        
        <tab label="Second"/>        
    </tabs>    
    <tabpanels>    
        <tabpanel>The first panel.</tabpanel>        
        <tabpanel>The second panel</tabpanel>        
    </tabpanels>    
</tabbox>

The currently selected tab component is given an additional selected property which is set to true. This is used to give the currently selected tab a different appearance so that it will look selected. Only one tab will have a true value for this property at a time.

There are two way to change the selected tab by Java codes. They are equivalent as shown below.

tab1.setSelected(true);
tabbox.setSelectedTab(tab1);

Of course, you can assign true to the selected property directly.

<tab label="My Tab" selected="true"/>

If none of tabs are selected, the first one is selected automatically.