views:

556

answers:

1

hi, i am adding widgets to a horizontal panel, and i want them to be all once next to the other on the left corner.

even though i have set the spacing=0 and alignment= left the widgets still have space between them. they are spread evenly in the panel.

please see the code here for the widget C'tor and the function that adds a new tab (toggle button) tabsPanel is a horizontalPanel, that you can see is aligned to left/right according to the locale

any advise would be appreciated thanks....

public TabsWidgetManager(int width, int height, int tabs_shift_direction){ 
    DecoratorPanel decorContent = new DecoratorPanel();
    DecoratorPanel decorTitle = new DecoratorPanel();
    widgetPanel.setSize(Integer.toString(width), Integer.toString(height));

    tabsPanel.setSize(Integer.toString(UIConst.USER_CONTENT_WIDTH), Integer.toString(UIConst.TW_DEFAULT_TAB_HEIGHT));
    tabsPanel.setSpacing(0);

    if (tabs_shift_direction==1)
        tabsPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
    else
        tabsPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
    decorTitle.add(tabsPanel);

    contentPanel.setSize(Integer.toString(UIConst.USER_CONTENT_WIDTH), Integer.toString(UIConst.USER_CONTENT_MINUS_TABS_HEIGHT));
    decorContent.add(contentPanel);
    widgetPanel.add(decorTitle, 0, 0);

    widgetPanel.add(decorContent, 0, UIConst.TW_DEFAULT_TAB_HEIGHT+15);

    initWidget(widgetPanel);
}

public void addTab(String title, Widget widget){
    widget.setVisible(false);
    ToggleButton tab = new ToggleButton(title);
    tabsList.add(tab);
    tab.setSize(Integer.toString(UIConst.TW_TAB_DEFAULT_WIDTH), Integer.toString(UIConst.TW_TAB_DEFAULT_HEIGHT));
    tab.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            handleTabClick((ToggleButton)event.getSource());

        }
    });

    //adding to the map
    tabToWidget.put(tab, widget);

    // adding to the tabs bar 
    tabsPanel.add(tab);
    //adding to the content
    contentPanel.add(widget);
}
A: 

I assume contentPanel is your HorizontalPanel. HorizontalPanel will generate an html table. You're setting the width of the panel. If the width is wider than the sum of all widths of your sub widgets the table will spread the widgets evenly. Remove the setWidth() call.

Eduard Wirch