How to user TabPanel programmatically

177 views
Skip to first unread message

Szemere

unread,
Oct 4, 2012, 11:33:52 AM10/4/12
to gwt-bo...@googlegroups.com
I'm having trouble understanding what is the appropriate way to add a TabPane and/or TabLink to a TabPanel from Java, as I'm not currently able to use UIBinder.

Among other things, I've tried:
TabPanel panel = TabPanel();
TabPane pane = new TabPane();
TabLink link = new TabLink(pane);

pane.add(widget);
link.setTitle("Test");

panel.add(link);
panel.add(pane);


But all that I see appear are all the panes at the same time.

Is this the right way to have both a TabPane and a TabLink? Which do I add to the TabPanel? To which do I add my widget? Does my widget need to be a particular layout panel?

Any help or pointers much appreciated.

Szemere

unread,
Oct 4, 2012, 6:15:39 PM10/4/12
to gwt-bo...@googlegroups.com
Looking at the source of TabPanel,  I suspect that a TabPane, TabLink combo needs to be created in "just the right way". I've tried:
    private TabLink createTabLink(String title, String html) {
        TabLink tabLink = new TabLink();
        tabLink.setText(title);
        tabLink.setTitle(title);
        TabPane tabPane = new TabPane(tabLink.getText());
        tabLink.setTablePane(tabPane);
        tabLink.setCreateTabPane(false);
       
        return tabLink;
    }


but that didn't seem to work. Only the links display, not the content. I see an NPE in onShow-->ShowEvent()->... with this code.

Also, I'll submit a patch for the comment typos and symmetric deficiencies (where a lack of symmetry in the code worries me) over the weekend.

Ohashi, Keisuke

unread,
Oct 5, 2012, 4:11:53 AM10/5/12
to gwt-bo...@googlegroups.com
Hi.

Sorry , right now TabPanel has this issue.
In few days , I'll fix it.

Szemere

unread,
Oct 5, 2012, 4:57:38 AM10/5/12
to gwt-bo...@googlegroups.com
Thanks. In the meantime, I've found a workaround. I create the TabPanel with UIBinder and at least one tab and then I can programmatically add tabs.
Reply all
Reply to author
Forward
0 new messages