2010-03-23 2 views
1

간단한 질문 .... , 나는 그것이 GWT 예 http://gwt.google.com/samples/Mail/Mail.html 유사 오른쪽에 내 DockLayoutPanel에서 동적으로로드 위젯을 가지고 ... 클릭합니다 .. 여기서 메일 박스 아래의 아무 항목이나 클릭하면 오른쪽에 다른 위젯이 표시됩니다 ...UiBinder 동적 DockPanel

+0

Mail 샘플의 원본을 보았습니까? http://code.google.com/p/google-web-toolkit/source/browse/#svn/trunk/samples/mail/src/com/google/gwt/sample/mail - 꽤 오래된 코드이지만 무슨 일이 일어나고 있는지의 기초가 있어야합니다. –

+0

제이슨, 나는 가지고있다 ... 그러나 StackLayoutPanel 항목에 관해서는 Dock Panel 레이아웃 영역 중 하나에서 위젯을 동적으로 질문하는 것에 대해서는 대답하지 않는다. 모든 연기와 거울은 그 점에서 – murray

+0

이다. 클릭 이벤트를 기반으로 한 위젯을 다른 위젯으로 바꾸는 방법, 맞습니까? –

답변

1

사용중인 특정 위젯을 사용하지 않았지만 일반적인 생각입니다.

public class Index implements EntryPoint { 

    public void onModuleLoad() { 
     // the panel that holds the content widgets 
     final SimplePanel mainPanel = new SimplePanel(); 
     // the panel that holds the links 
     FlowPanel leftPanel = new FlowPanel(); 
     // the first content widget 
     final Label oneContent = new Label("one content"); 
     // the second content widget 
     final Label twoContent = new Label("two content"); 
     // the anchor to load the first content widget when clicked 
     Anchor one = new Anchor("one menu"); 
     // add the click handler to do the content swap 
     one.addClickHandler(new ClickHandler() { 

      @Override 
      public void onClick(ClickEvent event) { 
       // remove any previous content 
       mainPanel.clear(); 
       // add the first content widget 
       mainPanel.add(oneContent); 
      } 
     }); 

     // the anchor to load the first content widget when clicked 
     Anchor two = new Anchor("two menu"); 
     // add the click handler to do the content swap 
     two.addClickHandler(new ClickHandler() { 

      @Override 
      public void onClick(ClickEvent event) { 
       // remove any previous content 
       mainPanel.clear(); 
       // add the second content widget 
       mainPanel.add(twoContent); 
      } 
     }); 

     leftPanel.add(one); 
     leftPanel.add(two); 
     // add everything to the RootPanel 
     RootPanel.get().add(leftPanel); 
     RootPanel.get().add(mainPanel); 
    } 
}