0
我是GWT新手。我用VerticalPanel創建了Stack DockLayoutPanel並添加了錨鏈接。現在我的下一個任務是在點擊左側導航鏈接時渲染表單。GWT渲染形式在中心點擊左側導航菜單Hyper Link
嘗試了很多方法,但未能成功。有人可以請幫忙嗎?
public class WebAppExample implements EntryPoint {
StackLayoutPanel stackPanel = new StackLayoutPanel(Unit.PX);
/**
* This is the entry point method.
*/
public void onModuleLoad() {
final DockLayoutPanel dockLayoutPanel = new DockLayoutPanel(Unit.PX);
Label headerLabel = new Label();
headerLabel.setText("Example Application");
headerLabel.addStyleName("northPanel");
stackPanel.setPixelSize(300, 999);
stackPanel.add(createMenuItem(),"Menus Navigation",40);
dockLayoutPanel.addNorth(headerLabel, 48);
dockLayoutPanel.addSouth(new FlowPanel(), 48);
dockLayoutPanel.addWest(stackPanel,300);
final Panel centerPanel = new FlowPanel();
dockLayoutPanel.add(new ScrollPanel(centerPanel));
//dockLayoutPanel.add(vPanel);
RootLayoutPanel.get().add(dockLayoutPanel);
}
private Widget createMenuItem() {
// Create a popup to show the contact info when a contact is clicked
HorizontalPanel menuPopupContainer = new HorizontalPanel();
menuPopupContainer.setSpacing(5);
//contactPopupContainer.add(new Image(images.defaultContact()));
final HTML contactInfo = new HTML();
menuPopupContainer.add(contactInfo);
final PopupPanel contactPopup = new PopupPanel(true, false);
contactPopup.setWidget(menuPopupContainer);
ArrayList<String> leftMenuItems = new ArrayList<String>();
leftMenuItems.add("Link1");
VerticalPanel menuVPanel = new VerticalPanel();
menuVPanel.setSpacing(4);
for (String menu : leftMenuItems) {
final Anchor contactLink = new Anchor(menu);
menuVPanel.add(contactLink);
}
return new SimplePanel(menuVPanel);
}
所以我們真的需要更多的細節,而不是成功。你也可能想看看gwt UI綁定器來處理你的佈局。它使處理用戶界面更容易,你可以輕鬆地將小部件和html混合在一起。 http://www.gwtproject.org/doc/latest/DevGuideUiBinder.html –