2010-01-14 37 views
1

我正在將小部件添加到水平面板,並且我希望它們在左上角一次都是相鄰的。GWT水平面板中的原因不明的間距

即使我已經設置了spacing = 0和alignment = left,這些小部件之間仍然有空間。它們均勻分佈在面板中。

請在這裏看到的代碼用於微C'tor並增加了一個新的標籤(切換按鈕) tabsPanel是horizo​​ntalPanel的功能,你可以看到對齊根據現場左/右

任何意見,將不勝感激 感謝....

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); 
} 
+0

請問您可以發佈一些示例代碼。要將哪個面板添加到水平面板?在水平面板中添加的小部件之間是否有間距?或整個水平面板的左側有空間嗎? – DonX 2010-01-15 02:22:35

+0

查看製作的HTML(使用FF中的FireBug)並檢查樣式。 – Drejc 2010-01-15 15:27:32

回答

0

我認爲contentPanel是你Horizo​​ntalPanel。 Horizo​​ntalPanel將生成一個html表格。你正在設置面板的寬度。如果寬度大於子窗口小部件所有寬度的總和,則表格將均勻地分散窗口小部件。取消撥打setWidth()