Problem using StackLayoutPanel
I am having problems using a StackPanel Layout. It does not work. It just shows the headings but no labels. Even the example from the documentation does not work:
http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/user/client/ui/StackLayoutPanel.html
java:
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Widget;
public class NavigationWidget extends Composite implements HasText {
private static NavigationWidgetUiBinder uiBinder = GWT
.create(NavigationWidgetUiBinder.class);
interface NavigationWidgetUiBinder extends
UiBinder<Widget, NavigationWidget> {
}
public NavigationWidget() {
initWidget(uiBinder.createAndBindUi(this));
}
public void setText(String text) {
}
public String getText() {
return null;
}
}
xml:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel>
<g:StackLayoutPanel unit='PX'>
<g:stack>
<g:header size='30'>
People
</g:header>
<g:VerticalPanel>
<g:Label>People Item 1</g:Label>
<g:Label>People Item 2</g:Label>
<g:Label>People Item 3</g:Label>
<g:Label>People Item 4</g:Label>
</g:VerticalPanel>
开发者_开发技巧 </g:stack>
<g:stack>
<g:header size='30'>
Groups
</g:header>
<g:VerticalPanel>
<g:Label>Group Item 1</g:Label>
<g:Label>Group Item 2</g:Label>
<g:Label>Group Item 3</g:Label>
<g:Label>Group Item 4</g:Label>
</g:VerticalPanel>
</g:stack>
<g:stack>
<g:header size='30'>
Settings
</g:header>
<g:VerticalPanel>
<g:Label>Item 5</g:Label>
<g:Label>Item 6</g:Label>
<g:Label>Item 7</g:Label>
<g:Label>Item 8</g:Label>
</g:VerticalPanel>
</g:stack>
</g:StackLayoutPanel>
</g:HTMLPanel>
</ui:UiBinder>
All LayoutPanel
s must be in a container that implements ProvidesResize
, or have their size explicitly set in code. The easiest thing for you to do is set the size of the StackLayoutPanel explicitly: just add height="100%"
to your <StackLayoutPanel>
element.
For more control, change your Composite
base class to ResizeComposite
and get rid of the <g:HTMLPanel>
element - just make the StackLayoutPanel the root element of your ui.xml file. You'll also have to make sure that you only use the NavigationWidget
in other LayoutPanel
s - for instance, you wouldn't add it to RootPanel.get()
, but instead to RootLayoutPanel.get()
For more info, see http://code.google.com/webtoolkit/doc/latest/DevGuideUiPanels.html
精彩评论