Tabs won't show off if coded

46 views
Skip to first unread message

patricc...@gmail.com

unread,
Feb 16, 2014, 8:25:25 AM2/16/14
to codenameone...@googlegroups.com
Hello everybody,

I'm just trying to create the tabs from the Designer via code.
And I did something like this:

 public void start() {
      
        Form main = new Form("Stories");
        main.setLayout(new BorderLayout());
        Tabs t = new Tabs(Component.BOTTOM);
        t.setLayout(new BorderLayout());
        Container stories = new Container();
        stories.setLayout(new BorderLayout());
        stories.addComponent(BorderLayout.WEST,new Label("test"));
        stories.addComponent(BorderLayout.CENTER,new Label("test"));
        stories.addComponent(BorderLayout.EAST,new Label("test"));
        
        Container messages = new Container();
        messages.setLayout(new BorderLayout());

        t.addTab("Stories",stories);
        t.addTab("Messages",messages);
        t.showTabs();
        t.addSelectionListener(new SelectionListener() {
public void selectionChanged(int oldSelected, int newSelected) {
}
});
        main.addComponent(BorderLayout.CENTER,t);
        main.show();
    }


But there are problems I mean the tabs only appear sometimes, or only after rotating the device in the simulator, and the tabs are without content, so i can't see the containers contant.

What could be the problem here ?
Thank you
Patric

Chen Fishbein

unread,
Feb 16, 2014, 9:13:49 AM2/16/14
to codenameone...@googlegroups.com, patricc...@gmail.com
Hi,
Remove this t.setLayout(new BorderLayout());
You shouldn't modify the Tabs layout.

patricc...@gmail.com

unread,
Feb 16, 2014, 11:30:07 AM2/16/14
to codenameone...@googlegroups.com, patricc...@gmail.com
Hi,
thank you for you'r answer!

I tried it, now i can see the Labels of the container, but still the problem that the Tabs are rendered only some times, or only after i rotate the simulator.

Thanks

Shai Almog

unread,
Feb 16, 2014, 2:03:30 PM2/16/14
to codenameone...@googlegroups.com, patricc...@gmail.com
Hi,
just ran this without a problem:
        Form main = new Form("Stories");
        main
.setLayout(new BorderLayout());
       
Tabs t = new Tabs(Component.BOTTOM);

       
Container stories = new Container();
        stories
.setLayout(new BorderLayout());
        stories
.addComponent(BorderLayout.WEST,new Label("test"));
        stories
.addComponent(BorderLayout.CENTER,new Label("test"));
        stories
.addComponent(BorderLayout.EAST,new Label("test"));
       
       
Container messages = new Container();
        messages
.setLayout(new BorderLayout());

        t
.addTab("Stories",stories);
        t
.addTab("Messages",messages);

       
//t.showTabs();
Reply all
Reply to author
Forward
0 new messages