GWT 中水平面板中无法解释的间距
我正在将小部件添加到水平面板中,并且我希望它们全部位于左上角的另一个小部件旁边。
即使我设置了间距 = 0 和对齐 = 左,小部件之间仍然有空间。它们均匀地分布在面板中。
请参阅此处小部件 C'tor 的代码以及添加新选项卡的功能(切换按钮) tabsPanel 是一个水平面板,您可以看到它根据区域设置左/右对齐,
任何建议将不胜感激 谢谢....
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);
}
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设
contentPanel
是您的 HorizontalPanel。 HorizontalPanel 将生成一个 html 表格。您正在设置面板的宽度。如果宽度比子小部件所有宽度的总和更宽,则表格将均匀地分布小部件。删除setWidth()
调用。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 thesetWidth()
call.